firebase / FirebaseUI-Android

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

com.firebase.ui.auth.FirebaseUiException: There was an error while trying to get your package certificate hash. #1962

Open edenman opened 3 years ago

edenman commented 3 years ago

Step 1: Are you in the right place?

Yes

Step 2: Describe your environment

Step 3: Describe the problem:

I get error reports from Sentry that look like this. This appears to be part of the automated build validation stuff that the Play store runs (I don't have any espresso tests in my codebase). Is there any way we could have this exception be a different type? Or have a unique+known error code so I can filter it out?

Firebase auth error (code=0)
com.firebase.ui.auth.FirebaseUiException: There was an error while trying to get your package certificate hash.
    at com.google.android.gms.internal.firebase-auth-api.zzto.zza(com.google.firebase:firebase-auth@@21.0.1:26)
    at com.google.firebase.auth.internal.zzav.onReceive(com.google.firebase:firebase-auth@@21.0.1:19)
    at androidx.localbroadcastmanager.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:313)
    at androidx.localbroadcastmanager.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:121)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at androidx.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:10)
    at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:7)
    at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:1)
    at androidx.test.espresso.base.UiControllerImpl.loopMainThreadForAtLeast(UiControllerImpl.java:8)
    at androidx.test.espresso.action.Tap$1.sendTap(Tap.java:4)
    at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:4)
    at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:2)
    at androidx.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:19)
    at androidx.test.espresso.ViewInteraction.access$100(ViewInteraction.java:1)
    at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:2)
    at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
samtstern commented 3 years ago

@edenman hmmm I'm open to catching this better but I actually think this is related to the Android SDK itself: https://github.com/FirebaseExtended/flutterfire/issues/4651

It's possible that we need to update our browser dependency. IIRC the reason I haven't done that yet is because browser introduced a requirement for Java 8 in a minor version (which should have been a breaking change) and I don't want to require Java 8 to use FirebaseUI.

That said, we can make that breaking change in FirebaseUI 8.0 and that's probably for the best.

edenman commented 3 years ago

That issue you linked to doesn't seem related, what part of that looks the same to you? Did I just miss it?

samtstern commented 3 years ago

@edenman hmmm reading it again I think you're right, I was probably confused. Not sure what I saw the first time.

I still don't quite see this as a FirebaseUI issue though. Somehow your app is running in a signing configuration that doesn't match what's registered with Play/Firebase. Is there a way you can get the SHA hash of that configuration and register it to avoid the crash?

edenman commented 3 years ago

1) I'm not sure how the Play store is generating the build with the invalid sha+packageName so I don't know how to even begin figuring out what to register 2) The FirebaseUI part of this is that it would be great if we could differentiate the exception type instead of having it be a generic opaque com.firebase.ui.auth.FirebaseUiException

samtstern commented 3 years ago

Ok we can add this to the list of known exceptions I think, although you should probably also try to find out where that strangely signed APK comes from!

edenman commented 3 years ago

It's definitely some sort of Play Store validation (maybe the pre-launch report?). The app is sideloaded (packageManager.getInstallerPackageName is null).

I use App Signing in the play store so I thought maybe the Play Store was trying to test out the uploadKey-signed app. Tried adding the upload key SHA-1/SHA-256 to the firebase app config, but that didn't help.

Maybe Play Store is taking the aab I upload and extracting the apks with some different signing key? bundletool uses the debug signing key by default, maybe that's the problem?

Anyway it'd be rad if I could filter these exceptions out somehow. The build I uploaded has functioning authentication.