其他分享
首页 > 其他分享> > Google使用Firebase登录Android – statusCode DEVELOPER_ERROR

Google使用Firebase登录Android – statusCode DEVELOPER_ERROR

作者:互联网

我尝试在Firebase连接的Android应用中实施Google登录.
当我运行应用程序并按Google登录按钮时 – 没有任何反应.我在onActivityResult中收到此错误:
状态{statusCode = DEVELOPER_ERROR,resolution = null}.

我的代码看起来像这样:

     protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == REQUEST_CODE_GOOGLE_LOGIN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);

        if (result.isSuccess()){
            GoogleSignInAccount account = result.getSignInAccount();
            String emailAddres = account.getEmail();
            getGoogleQAuthToken(emailAddres);
        }
    }
}

         private void getGoogleQAuthToken(final String emailAddres){
             AsyncTask<Void,Void,String> task = new AsyncTask<Void, Void, String>() {
                 String errorMessage = null;

                 @Override
                 protected String doInBackground(Void... params) {
                     String token = null;
                     try {
                         String scope = "oauth2:profile email";
                         token = GoogleAuthUtil.getToken(MainActivity.this, emailAddres, scope);
                     } catch (IOException transientEx) {

                         errorMessage = "Network error: " + transientEx.getMessage();
                     } catch (UserRecoverableAuthException e) {
                         Intent recover = e.getIntent();
                         startActivityForResult(recover, MainActivity.REQUEST_CODE_GOOGLE_LOGIN);
                     } catch (GoogleAuthException authEx) {
                         errorMessage = "Error authenticating with Google: " + authEx.getMessage();
                     }
                     return token;
                 }

我在app /目录中添加了JSON配置文件并添加了依赖项:

     buildscript {
repositories {
    jcenter()
}

dependencies {
    classpath 'com.google.gms:google-services:1.5.0-beta2'
}
     }


     dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.+'
compile 'com.firebase:firebase-client-android:2.3.0+'

/* For Google Play Services */
compile 'com.google.android.gms:play-services-safetynet:8.3.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'

compile('com.afollestad.material-dialogs:core:0.8.3.0@aar') {
    transitive = true
}

/* Firebase UI */
compile 'com.firebaseui:firebase-ui:0.2.2'

compile 'com.android.support:cardview-v7:23.1.+'
compile 'com.android.support:recyclerview-v7:23.1.+'
compile 'com.android.support:design:23.1.+'


     }
     apply plugin: 'com.google.gms.google-services'

我正在寻找解决方案的时间……
请帮忙!!

解决方法:

DEVELOPER_ERROR表示Google Play服务无法根据您的SHA1和程序包名称从控制台中找到匹配的客户端.您可以在Firebase console的设置页面中为给定的包名添加SHA1,或者通过添加Firebase将新包名添加到您的Android应用按钮.

一般来说,有些事情需要检查:

>确保您的包装名称符合您的预期 – 例如它是build.gradle中的那个,并且它没有在构建变体或产品风格中被覆盖.
>确保已在控制台中注册了调试并释放SHA1密钥.

标签:firebaseui,google-authentication,android,firebase,firebase-authentication
来源: https://codeday.me/bug/20190928/1828754.html