Flutter应用上架Play Store后Firebase登录相关崩溃问题求助
Hey there, let's tackle this crash issue you're hitting with your Flutter app post-deployment to Google Play Store. The crash happens in SignInHubActivity with a NullPointerException when calling String.equals() on a null reference—this usually ties back to misconfigured Google Services or Firebase Auth setup, especially since the app works locally but breaks on Play Store.
First, let's recap the crash log for clarity:
com.google.android.gms.auth.api.signin.internal.SignInHubActivity}: java.lang.NullPointerException: Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.RandstadRecruiter/com.google.android.gms.auth.api.signin.internal.SignInHubActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' 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)
Here are the most likely fixes to resolve this:
Upgrade Google Services Plugin Version
You're usingclasspath 'com.google.gms:google-services:4.2.0'which is quite outdated. Old versions often have compatibility issues with newer Firebase SDKs and Play Store's signing infrastructure. Update this in your project-levelbuild.gradleto the latest stable version (e.g.,classpath 'com.google.gms:google-services:4.3.15'—check for the latest stable release if needed).Sync Firebase Auth Plugin to Latest Stable Version
Outdatedfirebase_authpackages can clash with newer Google Services. Open yourpubspec.yaml, update the dependency to the latest stable release (e.g.,firebase_auth: ^4.10.0), then runflutter pub getto fetch the latest version.Add Play Store Signing SHA-1 to Firebase Console
When you upload your app to Play Store, Google re-signs it with their own certificate. If you only added your local debug/release SHA-1 to Firebase, this will cause authentication failures. Here's how to fix it:- Go to your Google Play Console, select your app → App signing under "Release".
- Copy the SHA-1 fingerprint from the "App signing certificate" section.
- Head to your Firebase Console, open your project → Project Settings → select your existing Android app.
- Paste the copied SHA-1 into the corresponding field, save changes, and download the updated
google-services.json. - Replace the
google-services.jsonin your Flutter project'sandroid/appdirectory with this new file.
Verify
google-services.jsonConfiguration
Double-check that thegoogle-services.jsonfile in your project has the correct package name (com.RandstadRecruiteras seen in the crash log) and matches the Firebase project you're using. A mismatch here can lead to unexpected null references during auth flows.Clean and Rebuild Your Project
Cached build artifacts can sometimes cause configuration issues. Runflutter cleanto clear old builds, then rebuild your app withflutter build appbundle(for Play Store) orflutter build apk, and re-upload the new build to Play Store.
After applying these steps, the crash should be resolved as the auth flow will have all the correct configuration to work with Play Store's signed app.
内容的提问来源于stack exchange,提问作者user4246398

