FirebaseUI-Android: NullPointerException AppCompatBase.java:32
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.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 23 (7 by maintainers)
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
Bump, encountering same issue
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?
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 reachedEmailLinkErrorRecoveryActivity
. And in that activity, superAppCompatBase
activity’sonCreate
method got called which in turn set the theme by callinggetFlowParams
method, which tries to getFlowParameters
from the intent. But sinceHelperActivityBase
has null check while creating the intent, I believe the problem is caused byKickoffActivity
’sinvalidateEmailLink
method.Steps to reproduce: Call
KickoffActivity
’sinvalidateEmailLink
method without providing the theme to theAuthUI
instanceSignInIntent
builder (this is an educated guess, I’m not sure how to call this method locally).Having a similar issue. A possible reason to why
.themeId
is called on null instance ofFlowParameters
is explained in #1729.