4

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?

Lak
  • 381
  • 1
  • 5
  • 23
  • 1
    having same problem i added requestIdToken and now it is returning false, got anything yet ?? – Sudhanshu Gaur Jan 15 '16 at 21:49
  • Please read my answer at http://stackoverflow.com/questions/33892546/how-can-i-get-profile-like-gender-from-google-signin-in-android/33906880#33906880 to see if it can help you or not – BNK Jan 16 '16 at 01:18
  • That didn't help and I have no idea why. – Lak Jan 19 '16 at 02:02
  • When you clicked on Signin button, the account picker displayed or not? – BNK Jan 19 '16 at 08:28
  • It displays. then after I click on that, the activity loads for sometime, then stay on the same activity.It doesn't start the next activity. my logcat says that both GoogleSignInResult and handleSignInResult returns false. – Lak Jan 22 '16 at 11:30
  • @Lak if my answer worked for you then please accept it, otherwise pls let me know if problem still persists. – Sudhanshu Gaur Aug 12 '16 at 15:56

1 Answers1

14

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

Sudhanshu Gaur
  • 7,486
  • 9
  • 47
  • 94
  • 2
    This should be marked as the answer. Generating a signed APK and placing it in the downloads folder of my phone, then using the file manager to locate and install the APK worked for me. Thank you. – Chad Mx Aug 16 '16 at 14:14