firebase / FirebaseUI-Android

Optimized UI components for Firebase
https://firebaseopensource.com/projects/firebase/firebaseui-android/
Apache License 2.0
4.63k stars 1.84k forks source link

NullPointerException AppCompatBase.java:32 #1650

Open zjamshidi opened 5 years ago

zjamshidi commented 5 years ago

Describe your environment

Describe the problem:

I'm using firebase authentication on my android app and recently I got an email regarding significant number of crashes with this stack trace: Caused by java.lang.NullPointerException: Attempt to read from field 'int com.firebase.ui.auth.a.a.d.c' on a null object reference at com.firebase.ui.auth.ui.AppCompatBase.onCreate + 32(AppCompatBase.java:32) at com.firebase.ui.auth.ui.email.EmailActivity.onCreate + 72(EmailActivity.java:72)

Relevant Code:

    @NonNull
    public Intent buildSignInIntent() {
        List<AuthUI.IdpConfig> selectedProviders = new ArrayList<>();
        selectedProviders.add(new AuthUI.IdpConfig.EmailBuilder().build());
        selectedProviders.add(new AuthUI.IdpConfig.FacebookBuilder().build());
        selectedProviders.add(new AuthUI.IdpConfig.GoogleBuilder().build());

        AuthUI.SignInIntentBuilder builder = AuthUI.getInstance().createSignInIntentBuilder()
                .setLogo(AuthUI.NO_LOGO)
                .setTheme(R.style.AppTheme)
                .setIsSmartLockEnabled(!BuildConfig.DEBUG /* credentials */, true /* hints */)
                .setAvailableProviders(selectedProviders)
                .enableAnonymousUsersAutoUpgrade();

        AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout
                .Builder(R.layout.fragment_register)
                .setGoogleButtonId(R.id.custom_google_signin_button)
                .setEmailButtonId(R.id.custom_email_signin_button)
                .setFacebookButtonId(R.id.custom_facebook_signin_button)
                .setTosAndPrivacyPolicyId(R.id.custom_tos)
                .build();

        builder.setAuthMethodPickerLayout(customLayout);

        builder.setTosAndPrivacyPolicyUrls(Constants.TermsOfUseLink, Constants.PrivacyPolicyLink);

        return builder.build();
    }

How could I fix it? Thanks in advance.

samtstern commented 5 years ago

@zjamshidi the stack traces you have provided (mostly 'int com.firebase.ui.auth.a.a.d.c') are obfuscated which means it's basically impossible for us to debug this. Can you deobfuscate them using your proguard mapping file or try to reproduce it locally?

zjamshidi commented 5 years ago

Oh. Sorry. According to proguard mapping file

com.firebase.ui.auth.data.model.FlowParameters -> com.firebase.ui.auth.a.a.d:
    int themeId -> c

and the following is the full stack trace:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.storyshots.android/com.firebase.ui.auth.ui.email.EmailActivity}: java.lang.NullPointerException: Attempt to read from field 'int com.firebase.ui.auth.a.a.d.c' on a null object reference
       at android.app.ActivityThread.performLaunchActivity + 2665(ActivityThread.java:2665)
       at android.app.ActivityThread.handleLaunchActivity + 2726(ActivityThread.java:2726)
       at android.app.ActivityThread.-wrap12(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage + 1477(ActivityThread.java:1477)
       at android.os.Handler.dispatchMessage + 102(Handler.java:102)
       at android.os.Looper.loop + 154(Looper.java:154)
       at android.app.ActivityThread.main + 6119(ActivityThread.java:6119)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 886(ZygoteInit.java:886)
       at com.android.internal.os.ZygoteInit.main + 776(ZygoteInit.java:776)
       at de.robv.android.xposed.XposedBridge.main + 107(XposedBridge.java:107)
zjamshidi commented 5 years ago

I have already found #765 which seems the same crash, but they solved the issue with updating the FirebaseUI Version to 1.2.0 while I'm using much newer version.

samtstern commented 5 years ago

@zjamshidi thanks for the deobfuscation. So somehow we're calling .themeId on a null instance of FlowParameters. I am not sure how this could be happening. Have you been able to reproduce this locally at all?

zjamshidi commented 5 years ago

So somehow we're calling .themeId on a null instance of FlowParameters.

Yes. It seems like this.

Have you been able to reproduce this locally at all?

No. I cannot reproduce it on my devices. But In Firebase Console I see 2 users are affected by this crash and I received an email that this issue's causing a significant number of crashes!

palfonso commented 4 years ago

Crashlytics is reporting same error for my app from some users.

Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{xxxxx.myapp/com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity}: java.lang.NullPointerException: Attempt to read from field 'int com.firebase.ui.auth.data.model.FlowParameters.themeId' on a null object reference

Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{com.palfonsoft.match4app/com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity}: java.lang.NullPointerException: Attempt to read from field 'int com.firebase.ui.auth.data.model.FlowParameters.themeId' on a null object reference

Was this issue solved ?

palfonso commented 4 years ago

Info about the device reporting the error:

Version: 6.0 Device: Y6II

palfonso commented 4 years ago

Using firebase-ui-auth:6.0.2

implementation 'com.firebaseui:firebase-ui-auth:6.0.2'

palfonso commented 4 years ago

Issue is clearly documented in stackoverflow:

https://stackoverflow.com/questions/59431114/attempt-to-read-from-field-int-com-firebase-ui-auth-data-model-flowparameters-t

ranjan-malav commented 4 years ago

Having a similar issue. A possible reason to why .themeId is called on null instance of FlowParameters is explained in #1729.

samtstern commented 4 years ago

Some information from #1729:


I have Email, phone and Gmail sign-in functionality in the app. I'm not sure how to reproduce the bug but might have some idea why it happened.

While creating AuthUI instance, I don't provide any style to the builder and one of the users somehow reached EmailLinkErrorRecoveryActivity. And in that activity, super AppCompatBase activity's onCreate method got called which in turn set the theme by calling getFlowParams method, which tries to get FlowParameters from the intent. But since HelperActivityBase has null check while creating the intent, I believe the problem is caused by KickoffActivity's invalidateEmailLink method.

Steps to reproduce: Call KickoffActivity's invalidateEmailLink method without providing the theme to the AuthUI instance SignInIntent builder (this is an educated guess, I'm not sure how to call this method locally).

peterhav commented 3 years ago

Encountered the same issue, below the stack trace from Crashlytics (InvisibleActivityBase.java line 39, com.firebase.ui.auth.ui.InvisibleActivityBase.onCreate). I hope that this helps in finding the problem:

Caused by java.lang.NullPointerException: Attempt to read from field 'int q.e.a.a.i.a.b.F0' on a null object reference
       at com.firebase.ui.auth.ui.InvisibleActivityBase.onCreate(InvisibleActivityBase.java:39)
       at com.firebase.ui.auth.KickoffActivity.onCreate(KickoffActivity.java:36)
       at android.app.Activity.performCreate(Activity.java:7009)
       at android.app.Activity.performCreate(Activity.java:7000)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
       at android.app.ActivityThread.-wrap11(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Device: Nexus 5X, running 8.1.0 FirebaseUI version: 7.1.1

edenman commented 3 years ago

I just got a flurry of these crashes from Sentry. FirebaseUI 7.1.1, Firebase Auth 21.0.1

java.lang.RuntimeException: Unable to start activity ComponentInfo{chat.quill.android/com.firebase.ui.auth.ui.email.RecoverPasswordActivity}: java.lang.NullPointerException: Attempt to read from field 'int com.firebase.ui.auth.data.model.FlowParameters.themeId' on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
...
samtstern commented 3 years ago

I just can't figure this one out. It means getFlowParams() is returning null which means getIntent().getParcelableExtra(ExtraConstants.FLOW_PARAMS) is null. That shouldn't be possible in our codebase so there must be some situation where the Activity's intent can change and not include the old extras?

If anyone has any ideas, PRs welcome.

robapaul88 commented 3 years ago

java.lang.NullPointerException: Attempt to read from field 'int com.firebase.ui.auth.data.model.FlowParameters.themeId' on a null object reference at com.firebase.ui.auth.ui.InvisibleActivityBase.onCreate(InvisibleActivityBase.java) at com.firebase.ui.auth.KickoffActivity.onCreate(KickoffActivity.java)

Using com.firebaseui:firebase-ui-auth:8.0.0 The Crashlytics graph seems to indicate that it started reproducing after we've enabled email verification. It didn't reproduce on my device with the happy flow. Also, all 37 occurrences we got so far happened on two devices, both from Huawei with Android 6 (Mate 9 lite and Y6II) Can't some defaults be used when the FlowParameters end up null, just to prevent the crash?

Hussienfahmy commented 2 years ago

Any updates on this issue ? i have 5 users with different device manufactures getting the same error LGE Nexus 5X, Android: 8.1.0 Google Pixel 3 XL, Android 9 HUAWEI LIO-AL00, Android 10

But there is something weird, am getting this errors right away after releasing a new version of my app. Is there any chance that this devices are test devices ?!

Shailevy commented 2 years ago

Anyone on this ?

tudormot commented 2 years ago

Bump, encountering same issue

tcoxMonkeyCoder commented 1 year ago

I'm also seeing 3 Crashlytics reports on this from 3 different spots: CredentialSaveActivity, SingleSignInActivity, and KickoffActivity. They all look similar to this:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sadieactive.sadieactive.android/com.firebase.ui.auth.ui.credentials.CredentialSaveActivity}: java.lang.NullPointerException: Attempt to read from field 'int com.firebase.ui.auth.data.model.FlowParameters.themeId' on a null object reference
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
       at android.app.ActivityThread.-wrap11()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Caused by java.lang.NullPointerException: Attempt to read from field 'int com.firebase.ui.auth.data.model.FlowParameters.themeId' on a null object reference
       at com.firebase.ui.auth.ui.InvisibleActivityBase.onCreate(InvisibleActivityBase.java:39)
       at com.firebase.ui.auth.ui.credentials.CredentialSaveActivity.onCreate(CredentialSaveActivity.java:41)
       at android.app.Activity.performCreate(Activity.java:7009)
       at android.app.Activity.performCreate(Activity.java:7000)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
       at android.app.ActivityThread.-wrap11()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

I have some of my login code released to production but it's currently hidden behind a feature flag. So in my release configuration I never set up the AuthUI IdpConfig providers or launch a signInIntent. So my hunch is even including the library at all may be enough to cause the issue.

firebase-ui-auth version: 7.2.0 Device: Nexus 5X, Android 8.1.0 (all three reports are from the same user)

palfonso commented 1 year ago

I have this error stack in Crashlytics:

Caused by java.lang.NullPointerException: Attempt to read from field 'int com.firebase.ui.auth.data.model.FlowParameters.themeId' on a null object reference at com.firebase.ui.auth.ui.AppCompatBase.onCreate(AppCompatBase.java:33) at com.firebase.ui.auth.ui.idp.WelcomeBackIdpPrompt.onCreate(WelcomeBackIdpPrompt.java:82) at android.app.Activity.performCreate(Activity.java:7994) at android.app.Activity.performCreate(Activity.java:7978) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3404) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7664) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

6vedant commented 1 year ago

It is very sad to see Firebase Auth team unable to resolve the issue even after 3 years. It is reproducible in latest versions of firebase:

  implementation 'com.firebaseui:firebase-ui-auth:8.0.1'
 implementation 'com.google.firebase:firebase-auth:21.1.0'
 implementation 'com.google.firebase:firebase-auth-ktx:21.1.0'
6vedant commented 1 year ago

It worked for me. Adding below snippet, removed the NullPointerCrash. Please let me know if this is working for you as well for this issue:

added in AndroidManifest.xml

 <activity
            android:name="com.firebase.ui.auth.ui.phone.PhoneActivity"
            android:exported="false"
            android:label="PhoneAuthActivity"
            android:windowSoftInputMode="adjustResize|stateAlwaysVisible"
            tools:replace="android:label"/>
        added in styles.xml
  ```
   <style name="FirebaseUI" parent="Theme.AppCompat">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
mnk98 commented 1 year ago

I am also having issue something like above Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{com.airkast.WPROAM/com.firebase.ui.auth.ui.email.RecoverPasswordActivity}: java.lang.NullPointerException: Attempt to read from field 'int com.firebase.ui.auth.data.model.FlowParameters.themeId' on a null object reference

ghost commented 7 months ago

Same issue is happening to me. com.firebase.ui.auth.ui.InvisibleActivityBase.onCreate (InvisibleActivityBase.java:39)

Come on guys, how has this issue be going on? 5 years? That is #sad.