Google+登录-自定义登录按钮后,handleSignInResult返回false [英] Google+ signin - handleSignInResult returns false after customizing signin button
问题描述
我正在遵循Google提供的示例代码,以将Google plus与android集成. https://github.com/googlesamples/google-services/blob/master/android/signin/app/src/main/java/com/google/samples/quickstart/signin/SignInActivity.java
I'm following the sample code given by Google to integrate Google plus with android. https://github.com/googlesamples/google-services/blob/master/android/signin/app/src/main/java/com/google/samples/quickstart/signin/SignInActivity.java
在我添加如下更改之前,该代码示例运行得非常好.
That code sample worked perfectly fine until I added some changes as follows.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(Scopes.PLUS_LOGIN))
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
signinGoogleBtn = (SignInButton) findViewById(R.id.signingoogleBtn);
signinGoogleBtn.setSize(SignInButton.SIZE_STANDARD);
signinGoogleBtn.setScopes(gso.getScopeArray());
我将Google+范围添加到GoogleSignInOptions中,以自定义登录按钮.然后,GoogleSignInResult和handleSignInResult始终返回false.
I added Google+ scopes to GoogleSignInOptions in order to customize the signin button. Then GoogleSignInResult and handleSignInResult always returns false.
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
任何人都可以帮助我解决此问题吗?
Could anyone please help me to fix this issue?
推荐答案
嘿,我遇到了同样的问题,我认为在您的情况下,您没有将google-services.json文件放入应用程序文件夹中,或者您没有运行您签名的apk文件(如果是这种情况,请先签名apk,然后将此apk文件粘贴到您的手机中,然后从他们的手机打开),我的意思是不要从android studio中运行您的应用,因为这样做不会运行签名的apk文件在移动设备上.希望这能奏效:)
Hey i was having same problem, i think in your case either you have not put your google-services.json file inside your app folder or you are not running your signed apk file if this the case first sign your apk and then paste this apk file in your mobile and from their open it, i mean don't run your app from android studio because what it does is it does not run signed apk file on mobile device. Hope this works :)
这篇关于Google+登录-自定义登录按钮后,handleSignInResult返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!