Android-Firebase身份验证失败

时间:2018-10-04 11:30:34

标签: android firebase firebase-authentication

我正在开发一个简单的应用程序。 我在以下文档中使用了Firebase Auth。 https://firebase.google.com/docs/auth/android/firebaseui?authuser=0#top_of_page

在调试模式下,它可以正常工作。 在发布模式下,我创建一个Apk文件,然后直接安装它,并且效果也很好。

但是当我将其发布到PlayStore中并下载时,它失败了。

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
    super.onActivityResult(requestCode, resultCode, data)

    if (requestCode == RC_SIGN_IN) {
        val response = IdpResponse.fromResultIntent(data)

        if (resultCode == Activity.RESULT_OK) {
            val user = FirebaseAuth.getInstance().currentUser
            info("onActivityResult - ${user!!.email}")
            mPresenter.isAlreadyExistUser(user!!.email!!)
        } else {
            error("signIn failed - ${response!!.error}")  <-- Only when I downloaded it from playstore, it failed...
            response!!.error!!.printStackTrace()
        }
    }
}

W/System.err: com.firebase.ui.auth.FirebaseUiException: Code: 12500, message: 12500: 
W/System.err:     at com.firebase.ui.auth.data.remote.GoogleSignInHandler.onActivityResult(GoogleSignInHandler.java:106)
W/System.err:     at com.firebase.ui.auth.ui.idp.SingleSignInActivity.onActivityResult(SingleSignInActivity.java:121)

我试图找到错误代码12500,但我找不到。 怎么了?!

我在gradle中执行了“ signinReport”,然后添加了调试并将SHA-1释放到Firebase中。

然后我下载了“ google-services.json”。

我再次告诉您,它在调试apk和发行apk中都可以正常工作。 但是,当我将运行良好的发行版APK上传到PlayStore时,失败了。

我真的不知道...

1 个答案:

答案 0 :(得分:3)

Google会验证您的签名,删除该签名,并处理该软件包以生成基本APK,配置APK和动态功能APK(如果适用)。然后Google重新签署APK。因此,您必须在Firebase控制台中为您的应用添加新的SHA-1标志。 打开Google Play Console

选择发布管理 > 应用签名 enter image description here

使用提供的 SHA-1 作为Firebase。

相关问题