Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase Auth crash when R8 full mode obfuscation enabled #2124

Closed
audkar opened this issue Oct 31, 2020 · 25 comments
Closed

Firebase Auth crash when R8 full mode obfuscation enabled #2124

audkar opened this issue Oct 31, 2020 · 25 comments

Comments

@audkar
Copy link

audkar commented Oct 31, 2020

[READ] Step 1: Are you in the right place?

Y

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: 4.0
  • Firebase Component: Auth
  • Component version: 20.0.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

If application is build with android.enableR8.fullMode=true then crash happens during login using google Sign-in.
With setting android.enableR8.fullMode=false app runs fine.

Stacktrace:

Fatal Exception: com.google.firebase.FirebaseException: An internal error has occurred. [ Instantiation of JsonResponse failed! class com.google.android.gms.internal.firebase-auth-api.zzok ]
       at com.google.firebase.auth.api.internal.zzem.zza(com.google.firebase:firebase-auth@@20.0.0:29)
       at com.google.firebase.auth.api.internal.zzfx.zza(com.google.firebase:firebase-auth@@20.0.0:14)
       at com.google.firebase.auth.api.internal.zzfs.zza(com.google.firebase:firebase-auth@@20.0.0:44)
       at com.google.firebase.auth.api.internal.zzel.zza(com.google.firebase:firebase-auth@@20.0.0:10)
       at com.google.firebase.auth.api.internal.zzac.zza(com.google.firebase:firebase-auth@@20.0.0:2)
       at com.google.android.gms.common.util.DeviceProperties.zza(com.google.android.gms:play-services-basement@@17.1.1:131)
       at com.google.firebase.auth.api.internal.zzfn.zza(com.google.firebase:firebase-auth@@20.0.0:10)
       at com.google.firebase.auth.api.internal.zzep.zza(com.google.firebase:firebase-auth@@20.0.0:53)
       at com.google.firebase.auth.api.internal.zzda.accept(com.google.firebase:firebase-auth@@20.0.0:9)
       at com.google.android.gms.common.api.internal.zaf.zac(com.google.android.gms:play-services-base@@17.1.0:6)
       at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zac(com.google.android.gms:play-services-base@@17.1.0:2)
       at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zab(com.google.android.gms:play-services-base@@17.1.0:5)
       at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zaa(com.google.android.gms:play-services-base@@17.1.0:5)
       at com.google.android.gms.common.api.internal.GoogleApiManager.handleMessage(com.google.android.gms:play-services-base@@17.1.0:113)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at com.google.android.gms.internal.base.zar.dispatchMessage(com.google.android.gms:play-services-base@@17.1.0:1)
       at android.os.Looper.loop(Looper.java:223)
       at android.os.HandlerThread.run(HandlerThread.java:67)

Relevant Code:

val task = GoogleSignIn.getSignedInAccountFromIntent(result.data)
val account = task.getResult(ApiException::class.java)
val auth = FirebaseAuth.getInstance()
val credential = GoogleAuthProvider.getCredential(account.idToken, null)
val firebaseUser = auth.signInWithCredential(credential).await()
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@malcolmdeck
Copy link
Contributor

Hey there! I've filed b/172259754 to track this internally :)

@malcolmdeck
Copy link
Contributor

Ok, it appears that this only happens when you use android.enableR8.fullMode=true and not android.enableR8=true. That's a reasonable workaround while I figure out if there's a way to fix this.

To be noted: I think the root cause is a use of reflection at the network layer of the SDK. I don't yet know how to protect classes when using enableR8, so it's gonna take me a bit to see if this is a fixable problem via something like proguard rules or if I have to see if it's possible to fix the underlying issue itself.

@b95505017
Copy link

@malcolmdeck Any update? I don't want to turn off full mode of R8 just because upgrading firebase sdk.

@devaniumesh
Copy link

same problem here. in firebase latest sdk. When using android.enableR8.fullMode=true . it's release version not working

@valentynsmetanin
Copy link

valentynsmetanin commented Dec 22, 2020

It's still reproducing with:
android.enableR8.fullMode=true
com.google.firebase:firebase-bom:26.2.0
com.google.firebase:firebase-auth-ktx

@benjaminojanne
Copy link

benjaminojanne commented Jan 12, 2021

Hello
I found a solution to the problem today.
Go to proguard-rules.pro file and add this:

-keep class com.google.android.gms.internal.** { *; }

@b95505017
Copy link

@benjaminojanne Thanks but I think that will keep so many redundant thinks.

@b95505017
Copy link

@benjaminojanne It seems that you could specify to the path within auth library
-keep class com.google.android.gms.internal.firebase-auth-api.** { *; }

@nuhkoca
Copy link

nuhkoca commented Jun 29, 2021

Any update on this without requiring a path?

@TeGlobal
Copy link

TeGlobal commented Sep 16, 2021

Make sure you have these lines:

-keep public class com.google.firebase.** {*;}
-keep class com.google.android.gms.internal.** {*;}
-keepclasseswithmembers class com.google.firebase.FirebaseException

Thanks #2124 (comment)

@eakteam
Copy link

eakteam commented Dec 18, 2021

+1

@ronsivan1
Copy link

Didn't solve it for me

@iammannan
Copy link

Make sure you have these lines:

-keep public class com.google.firebase.** {*;} -keep class com.google.android.gms.internal.** {*;} -keepclasseswithmembers class com.google.firebase.FirebaseException

Thanks #2124 (comment)

thanks, it works

@ArcherEmiya05
Copy link

@benjaminojanne It seems that you could specify to the path within auth library -keep class com.google.android.gms.internal.firebase-auth-api.** { *; }

This show as error in proguard file, any idea why?

@ArcherEmiya05
Copy link

Make sure you have these lines:

-keep public class com.google.firebase.** {*;} -keep class com.google.android.gms.internal.** {*;} -keepclasseswithmembers class com.google.firebase.FirebaseException

Thanks #2124 (comment)

Is the other rule really necessary? Currently even with this line only in rule seems to solve the issue already.
-keep class com.google.android.gms.internal.** { *; }

@svenjacobs
Copy link

Now that Android Studio Flamingo with AGP 8.0 enabled R8 full mode by default, I'm facing the same issue.

Is there any chance the auth library could provide R8 consumer rules in its artifact?

@tekinarslan
Copy link

@svenjacobs you can add these lines into proguard and it works.

-keep public class com.google.firebase.** {;}
-keep class com.google.android.gms.internal.** {
;}
-keepclasseswithmembers class com.google.firebase.FirebaseException

@svenjacobs
Copy link

@svenjacobs you can add these lines into proguard and it works.

-keep public class com.google.firebase.** {;} -keep class com.google.android.gms.internal.** {;} -keepclasseswithmembers class com.google.firebase.FirebaseException

@tekinarslan I only added this line to my R8 rules as mentioned here and it works for me.

-keep class com.google.android.gms.internal.** { *; }

@martinbonnin
Copy link
Contributor

In case a reproducer is needed, this is happening joreilly/Confetti (Pull Request to keep classes).
Same conditions as others: happened after bumping AGP to 8.

@LeandroLCD
Copy link

-keep public class com.google.firebase.** {*;}
-keep class com.google.android.gms.internal.** {*;}
-keepclasseswithmembers class com.google.firebase.FirebaseException

el problema me persiste al modificar el archivo proguar:
image

@argzdev
Copy link
Contributor

argzdev commented May 24, 2023

Hi @LeandroLCD, not sure if this is the same issue. Could you file a new ticket with details from our template regarding your issue? Thanks!

@LouisCAD
Copy link

Hello, this is a particularly sneaky bug, a not nice at all pitfall that Google left on the path of developers AND users.

How close is this to be fixed on Firebase side?

@LouisCAD
Copy link

I mean, it was reported back in 2020, and despite reports, part of Google itself pulled the trigger to make R8 full mode default in STABLE Android Gradle Plugin, and other part of Google still hasn't reacted…

The consequences aren't great, please, prioritize this show-stopper.

@prameshj
Copy link

This has been fixed in https://firebase.google.com/support/release-notes/android#auth_v22-1-0

@firebase firebase locked and limited conversation to collaborators Aug 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests