firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.28k stars 578 forks source link

Firebase Auth initialization fails after relaunching app with signed-in user when minifyEnabled = true #6375

Closed dantheli closed 4 weeks ago

dantheli commented 1 month ago

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

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

With Firebase Auth 23.0.0 and minifyEnabled true, after signing in to Firebase Auth, quitting and relaunching the app should show a valid currentUser. Instead, instantiation of Firebase Auth fails with a JSON parsing error:

JSONArray[0] not a string.
s9.b: JSONArray[0] not a string.
    at s9.a.e(Unknown Source:21)
    at T6.x.a(Unknown Source:148)
    at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source:213)
    at com.google.firebase.auth.FirebaseAuthRegistrar.lambda$getComponents$0(Unknown Source:58)
    at S6.O.b(Unknown Source:11)
    at O6.d.get(Unknown Source:167)
    at U6.p.get(Unknown Source:13)
    at U6.c.f(Unknown Source:8)
    at U6.c.a(Unknown Source:4)
    at O6.h.b(Unknown Source:5)
    at com.google.firebase.auth.FirebaseAuth.getInstance(SourceFile:2)
    at G5.f.i0(Unknown Source:0)
    at N7.g.<clinit>(Unknown Source:47)
    at com.onme.giftcards.MainActivity.onCreate(Unknown Source:3)
    at android.app.Activity.performCreate(Activity.java:8975)
    at android.app.Activity.performCreate(Activity.java:8944)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4146)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4322)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:230)
    at android.os.Looper.loop(Looper.java:319)
    at android.app.ActivityThread.main(ActivityThread.java:8919)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

This frustratingly only occurs when uploaded to the Play Store—I'm unable to test locally as Firebase Auth expects a proper Play Store-signed app when in release mode.

Turning off minifyEnabled resolves this problem.

Steps to reproduce:

Relevant Code:

Simply adding a Firebase.auth.currentUser in onCreate will reproduce this issue.

I tried adding these Proguard rules to no avail.

-keep class com.google.firebase.** { *; }
-keep class com.google.android.gms.** { *; }
-keepclasseswithmembers class com.google.firebase.FirebaseException { *; }
-keepclasseswithmembers class com.google.firebase.auth.FirebaseAuthException { *; }
-keepnames class com.google.firebase.auth.** { *; }
-keepattributes Signature
-dontwarn com.google.firebase.**
google-oss-bot commented 1 month ago

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

lehcar09 commented 1 month ago

Hi @dantheli, thank you for reaching out. Can you the play-services-auth version you're using? Does the issue occur on certain devices and/or android versions?

dantheli commented 1 month ago

Thanks for your response @lehcar09. I'm not explicitly listing play-services-auth as a dependency, but should I?

It's occurring on all devices & Android versions we're trying- haven't found one that doesn't reproduce.

lehcar09 commented 1 month ago

Sorry, I was meant to ask for Android Gradle plugin version. The play-service-auth dependency is required for Firebase Auth Google provider and Email linking. If you're not using them, you don't need to add the dependency.

By any chance, can you share the gradle files you're using?

google-oss-bot commented 1 month ago

Hey @dantheli. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 4 weeks ago

Since there haven't been any recent updates here, I am going to close this issue.

@dantheli if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.