Google登录不适用于Android的发行版 [英] Google signin not working on release version of android

查看:133
本文介绍了Google登录不适用于Android的发行版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前的应用程序出现问题. 我的OAuth2.0 SHA1是正确的,并且是从发行版本的密钥库文件生成的. 我的问题是我每次在onActivityResult上都收到resultCode = 0. 我打印出意图的价值,并得到以下结果: googleSignInStatus =状态{statusCode = INTERNAL_ERROR,分辨率=空} 但是,如果我在调试模式下运行它,则登录可以正常工作,在这种情况下,intent的值是: googleSignInAccount=com.google.android.gms.auth.api.signin.GoogleSignInAccount@31976389]

I am getting problem for my current app. My OAuth2.0 the SHA1 is correct and generated from keystore file of release version. My problem is I am receiving resultCode =0 everytime on onActivityResult. I print out value of intent and got below: googleSignInStatus=Status{statusCode=INTERNAL_ERROR, resolution=null} But, if I run it on debug mode login working perfectly and for this case value of intent is: googleSignInAccount=com.google.android.gms.auth.api.signin.GoogleSignInAccount@31976389]

有人知道如何解决这个问题吗? 注意:在我发现某处的某个地方,他们建议将电子邮件和项目名称放在OAuth竞赛屏幕上.我已经尝试过了,但仍然无法正常工作.

Do anybody knows how to solve this problem. NOTE: Somewhere I found one post they recommend to put Email and Project name on OAuth Contest Screen; I already tried that and still not working.

推荐答案

显然,首先要检查您的发行版sha1键是否正确.但是这里的问题是不同的.我正在使用新的Google Play服务(即,编译"com.google.android.gms:play-services:8.4.0").通过修改GoogleSignInOption对象可以解决问题. 代替:

Obviously first check your release sha1 key is correct or not. But issue here was different. I am using new google play services (i.e.compile 'com.google.android.gms:play-services:8.4.0'). And issue could be solved by modifying GoogleSignInOption object. Instead of:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestEmail()  
       .requestIdToken("YOUR_WEB_API_ID.apps.googleusercontent.com")
                    .build();

我使用:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestScopes(new Scope(Scopes.PLUS_LOGIN))
                .requestScopes(new Scope(Scopes.PLUS_ME))
                .requestEmail()
                .build();

这解决了返回statusCode = INTERNAL_ERROR的错误. 然后,该gso对象可用于创建GoogleApiClient,如下所示:

This solves error returning statusCode=INTERNAL_ERROR . Then this gso object could be used for creating GoogleApiClient as shown below:

 mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this, this)
                .addApi(Auth.GOOGLE_SIGN_IN_API,gso)
               // .addApi(Plus.API, null)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
               // .addScope(Plus.SCOPE_PLUS_LOGIN)
                .build(); 

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

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