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 initialization fails after relaunching app with signed-in user when minifyEnabled = true #6375

Open
dantheli opened this issue Oct 11, 2024 · 4 comments

Comments

@dantheli
Copy link

dantheli commented Oct 11, 2024

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

@lehcar09
Copy link
Contributor

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
Copy link
Author

dantheli commented Oct 14, 2024

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
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants