FirebaseUI-Android icon indicating copy to clipboard operation
FirebaseUI-Android copied to clipboard

NullPointerException AppCompatBase.java:32

Open zjamshidi opened this issue 5 years ago • 24 comments

Describe your environment

  • Android device: motorola Nexus 6
  • Android OS version: 7.1.1
  • Google Play Services version: _____
  • Firebase/Play Services SDK version: 16.0.9
  • FirebaseUI version: 5.0.0

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.

zjamshidi avatar Jun 25 '19 12:06 zjamshidi

@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?

samtstern avatar Jun 25 '19 20:06 samtstern

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 avatar Jun 26 '19 02:06 zjamshidi

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.

zjamshidi avatar Jun 26 '19 02:06 zjamshidi

@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?

samtstern avatar Jun 26 '19 18:06 samtstern

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!

zjamshidi avatar Jun 27 '19 08:06 zjamshidi

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 avatar Dec 20 '19 19:12 palfonso

Info about the device reporting the error:

Version: 6.0 Device: Y6II

palfonso avatar Dec 20 '19 19:12 palfonso

Using firebase-ui-auth:6.0.2

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

palfonso avatar Dec 20 '19 20:12 palfonso

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

palfonso avatar Dec 20 '19 20:12 palfonso

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

ranjan-malav avatar Jan 27 '20 14:01 ranjan-malav

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

samtstern avatar Jan 31 '20 23:01 samtstern

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

peterhav avatar Jan 05 '21 08:01 peterhav

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

edenman avatar Jun 27 '21 20:06 edenman

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.

samtstern avatar Jun 30 '21 13:06 samtstern

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?

robapaul88 avatar Sep 07 '21 20:09 robapaul88

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 ?!

Hussienfahmy avatar Dec 13 '21 20:12 Hussienfahmy

Anyone on this ?

Shailevy avatar Sep 26 '22 20:09 Shailevy

Bump, encountering same issue

tudormot avatar Sep 29 '22 09:09 tudormot

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)

tcoxMonkeyCoder avatar Feb 22 '23 15:02 tcoxMonkeyCoder

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)

palfonso avatar Mar 08 '23 13:03 palfonso

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 avatar Mar 18 '23 04:03 6vedant

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>

6vedant avatar Mar 18 '23 08:03 6vedant

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

mnk98 avatar Jul 06 '23 08:07 mnk98

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.