Google 使用 Firebase 登录 Android - statusCode DEVELOPER_ERROR [英] Google sign-in Android with Firebase - statusCode DEVELOPER_ERROR

查看:32
本文介绍了Google 使用 Firebase 登录 Android - statusCode DEVELOPER_ERROR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在与 Firebase 连接的 Android 应用中实现 Google 登录.当我运行应用程序并按下 Google 登录按钮时 - 什么也没有发生.我在 onActivityResult 中收到此错误:状态{statusCode=DEVELOPER_ERROR,resolution=null}.

I try to implement Google login in my Firebase connected Android app. When I run the app and press Google Sign In button - nothing happen. And I receive this error in onActivityResult: Status{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 配置文件并添加了依赖项:

I've added JSON config file in app/ directory and added dependencies:

     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'

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

I am looking for solution hours already... Please help!!

推荐答案

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

DEVELOPER_ERROR means Google Play services was unable to find a matching client from the console based on your SHA1 and package name. You can add SHA1s in the settings page on the Firebase console for a given package name, or add a new package name through the Add Firebase to your Android app button.

一般来说,需要检查以下几点:

In general, some things to check for:

  • 确保您的包名称符合您的预期 - 例如它是您的 build.gradle 中的那个,并且不会在构建变体或产品风格中被覆盖.
  • 确保您已在控制台中注册调试和发布 SHA1 密钥.

这篇关于Google 使用 Firebase 登录 Android - statusCode DEVELOPER_ERROR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆