Google+ signin - handleSignInResult returns false after customizing signin button

有些话、适合烂在心里 提交于 2019-12-29 07:56:34

问题


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

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?


回答1:


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



来源:https://stackoverflow.com/questions/34808531/google-signin-handlesigninresult-returns-false-after-customizing-signin-butto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!