firebase-android-sdk: Firebase Auth crash when R8 full mode obfuscation enabled
[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()
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 13
- Comments: 25 (8 by maintainers)
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 https://github.com/firebase/firebase-android-sdk/issues/2124#issuecomment-759074412
@benjaminojanne It seems that you could specify to the path within auth library
-keep class com.google.android.gms.internal.firebase-auth-api.** { *; }
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.** { *; }
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.
This has been fixed in https://firebase.google.com/support/release-notes/android#auth_v22-1-0
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?
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?
Ok, it appears that this only happens when you use
android.enableR8.fullMode=true
and notandroid.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.
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.
@tekinarslan I only added this line to my R8 rules as mentioned here and it works for me.
same problem here. in firebase latest sdk. When using android.enableR8.fullMode=true . it’s release version not working
@malcolmdeck Any update? I don’t want to turn off full mode of R8 just because upgrading firebase sdk.