firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

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

Open dantheli opened this issue 1 year ago • 4 comments

[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:

  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • For general Firebase discussion, use the firebase-talk google group.
  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Android Studio Koala Feature Drop | 2024.1.2 Patch 1
  • Firebase Component: Auth
  • Component version: 23.0.0 (BOM 33.4.0)

[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:

  • Turn on minifyEnabled.
  • Build app in release mode
  • Upload to Google Play
  • Download the uploaded app
  • Sign in to the app
  • Restart the app
  • Observe error and that the user is not authenticated.

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.**

dantheli avatar Oct 11 '24 14:10 dantheli

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

google-oss-bot avatar Oct 11 '24 14:10 google-oss-bot

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?

lehcar09 avatar Oct 14 '24 11:10 lehcar09

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.

dantheli avatar Oct 14 '24 21:10 dantheli

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?

lehcar09 avatar Oct 15 '24 14:10 lehcar09

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 avatar Oct 22 '24 01:10 google-oss-bot

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.

google-oss-bot avatar Oct 29 '24 01:10 google-oss-bot