Firebase Auth Ui Google登录“Developer Error”

时间:2021-12-13 20:56:06

I have a project using firebase and the firebase auth ui library. The problem is I can't sign in using Google sign-in, when I try it loads for a second or two and then just shows a toast message saying "Developer Error". I can sign in with email and password just fine. And this is only a problem on signed apks, when I am debugging Google, sign-in works fine.

我有一个使用firebase和firebase auth ui库的项目。问题是我无法使用Google登录登录,当我尝试加载一两秒钟然后只显示一个Toast消息“Developer Error”。我可以用电子邮件和密码登录就好了。这只是签名apks的问题,当我调试Google时,登录工作正常。

In my proguard-rules.pro I have minifyEnabled set to false.

在我的proguard-rules.pro中,我将minifyEnabled设置为false。

And I have added the SHA-1 to my firebase project and have downloaded the correct json file.

我已将SHA-1添加到我的firebase项目并已下载正确的json文件。

dependency block from app level build.gradle

来自app level build.gradle的依赖块

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
})
    compile 'com.android.support:appcompat-v7:26.0.2'
    compile 'com.android.support:design:26.0.2'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:26.0.2'
    compile 'com.android.support:cardview-v7:26.0.2'
    compile 'com.google.firebase:firebase-database:11.4.2'
    compile 'com.google.firebase:firebase-auth:11.4.2'
    compile 'com.firebaseui:firebase-ui-auth:3.1.0'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

here is my AuthStateListener

这是我的AuthStateListener

mAuthStateListener = new FirebaseAuth.AuthStateListener() {
            @Override
            public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                FirebaseUser user = firebaseAuth.getCurrentUser();
                if (user != null) {
                    signedInInitialized();
                } else {
                    signedOutCleanUp();
                    startActivityForResult(
                            AuthUI.getInstance()
                                    .createSignInIntentBuilder()
                                    .setTheme(R.style.FirebaseSignInTheme)
                                    .setIsSmartLockEnabled(false)
                                    .setAvailableProviders(
                                            Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
                                                new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build()))
                                .build(),
                        RC_SIGN_IN);
                }
            }
        };

The logcat shows no error or anything. I would post the logcat when this happens but I don't know how to get the logcat from a signed apk cause this only happens on sign the apk.

logcat没有显示任何错误或任何错误。我会在发生这种情况时发布logcat,但我不知道如何从签名的apk获取logcat,因为这只发生在apk上。

I have tried to figure this out for days but seem to be making no head way.

我试图解决这个问题好几天,但似乎没有头脑。

Thanks

谢谢

4 个解决方案

#1


7  

You have added the signature of the debug key in the console. But the signature of release key is different. Add the signature of release key that you used to sign the apk in the firebase console.

您已在控制台中添加了调试密钥的签名。但是发布密钥的签名是不同的。添加用于在firebase控制台中对apk进行签名的释放密钥签名。

First generate key using following command:

首先使用以下命令生成密钥:

keytool -list -v -keystore KEYSTORE_PATH -alias ALIAS_NAME

Then copy the SHA-1 checksum and go to:

然后复制SHA-1校验和并转到:

Firebase Console > Your project > Settings of the app > Add Fingerprint

Firebase控制台>您的项目>应用程序的设置>添加指纹

#2


0  

You have added Both key

您已添加两个键

  1. Your android debug key SHA-1

    你的android调试密钥SHA-1

  2. Your signature of release key SHA-1

    您的释放密钥SHA-1的签名

#3


0  

The easiest way to do this is with android studio: Tools -> Firebase -> Authentication -> Click on the small play button, and press on the Connect button in the first option. Android studio will do it for you, generate the SHA-1 key and add it your project.

最简单的方法是使用android studio:工具 - > Firebase - >身份验证 - >单击小播放按钮,然后按第一个选项中的连接按钮。 Android studio将为您完成,生成SHA-1密钥并将其添加到您的项目中。

#4


0  

Google is getting more and more ugly, they're making simple things complicated. The problem is the third key,

谷歌变得越来越难看,他们让简单的事情变得复杂。问题是第三个关键,

1、the debug key

1,调试密钥

2、the release key

2,释放键

3、Google Play App signing key

3,Google Play App签名密钥

You need THREE keys to figure out ONE Google SignIn.

您需要三个键来确定一个Google SignIn。

Does facebook also need three keys? Maybe one day google will need 30 keys.

facebook还需要三个键吗?也许有一天谷歌将需​​要30键。

#1


7  

You have added the signature of the debug key in the console. But the signature of release key is different. Add the signature of release key that you used to sign the apk in the firebase console.

您已在控制台中添加了调试密钥的签名。但是发布密钥的签名是不同的。添加用于在firebase控制台中对apk进行签名的释放密钥签名。

First generate key using following command:

首先使用以下命令生成密钥:

keytool -list -v -keystore KEYSTORE_PATH -alias ALIAS_NAME

Then copy the SHA-1 checksum and go to:

然后复制SHA-1校验和并转到:

Firebase Console > Your project > Settings of the app > Add Fingerprint

Firebase控制台>您的项目>应用程序的设置>添加指纹

#2


0  

You have added Both key

您已添加两个键

  1. Your android debug key SHA-1

    你的android调试密钥SHA-1

  2. Your signature of release key SHA-1

    您的释放密钥SHA-1的签名

#3


0  

The easiest way to do this is with android studio: Tools -> Firebase -> Authentication -> Click on the small play button, and press on the Connect button in the first option. Android studio will do it for you, generate the SHA-1 key and add it your project.

最简单的方法是使用android studio:工具 - > Firebase - >身份验证 - >单击小播放按钮,然后按第一个选项中的连接按钮。 Android studio将为您完成,生成SHA-1密钥并将其添加到您的项目中。

#4


0  

Google is getting more and more ugly, they're making simple things complicated. The problem is the third key,

谷歌变得越来越难看,他们让简单的事情变得复杂。问题是第三个关键,

1、the debug key

1,调试密钥

2、the release key

2,释放键

3、Google Play App signing key

3,Google Play App签名密钥

You need THREE keys to figure out ONE Google SignIn.

您需要三个键来确定一个Google SignIn。

Does facebook also need three keys? Maybe one day google will need 30 keys.

facebook还需要三个键吗?也许有一天谷歌将需​​要30键。