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

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

问题描述

我尝试在Firebase连接的Android应用中执行Google登录。
当我运行应用程序,然后按Google登录按钮 - 什么也没有发生。我在onActivityResult中收到这个错误:
状态{statusCode = DEVELOPER_ERROR,resolution = null}
$ b 我的代码看起来像这样:

  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);



$ b 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;
试试{
String scope =oauth2:profile email;
token = GoogleAuthUtil.getToken(MainActivity.this,emailAddres,scope);
catch(IOException transientEx){

errorMessage =网络错误:+ transientEx.getMessage();
} catch(UserRecoverableAuthException e){
Intent recover = e.getIntent();
startActivityForResult(recover,MainActivity.REQUEST_CODE_GOOGLE_LOGIN);
} catch(GoogleAuthException authEx){
errorMessage =用Google验证错误:+ authEx.getMessage();
}
返回令牌;





我已经在app /目录中添加了JSON配置文件并添加了依赖关系: / p>

  buildscript {
repositories {
jcenter()
}

依赖关系{
classpath'com.google.gms:google-services:1.5.0-beta2'
}
}


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

/ *对于Google Play服务* /
编译'com.google.android.gms:play-services-safetynet:8.3 .0'
compile'c​​om.google.android.gms:play-services-auth:8.3.0'
compile'c​​om.google.android.gms:play-services:8.3.0'

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

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

compile'c​​om.android.support:cardview-v7:23.1.+'
compile'c​​om.android.support:recyclerview-v7:23.1.+'
compile'c​​om.android.support: design:23.1。+'


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

我正在寻找解决方案小时已经...
请帮助!!

解决方案

DEVELOPER_ERROR 意味着Google Play服务无法根据您的SHA1和软件包名称从控制台中找到匹配的客户端。您可以在 Firebase控制台上的设置页面中为给定的软件包名称添加SHA1,也可以通过将Firebase添加到您的Android应用按钮。



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


  • 确认你的包裹名字是你期望的 - 例如它是你的build.gradle中的一个,它不会在构建变体或产品风格中被重写。
  • 确保你已经在控制台中注册了你的调试和释放SHA1键。


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}.

My code looks like this:

     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;
                 }

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 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:

  • Make sure your package name is what you expect - e.g. its the one in your build.gradle, and its not being overriden in a build variant or product flavor.
  • Make sure you have registered your debug and release SHA1 keys in the console.

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

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