11

I've been facing some issues while integrating Google+ Signin functionality. So far, i've integrated all the necessary G+ Sign in API modules and codes which works good, generated and placed the google-services.json within /app after generating SHA1 using keytool of debug.keystore and pasted the SHA1 on the google cloud developer console, but now there's only one glitch i am facing since many days/weeks i.e. when i try to do device debuggin and whenever i click on "G+ Sign In" i get the following error in LogCat:

E/GMPM: getGoogleAppId failed with status: 10

E/GMPM: Uploading is not possible. App measurement disabled.

D/SignInActivity: handleSignInResult:false

This handleSignInResult is returning False all the time and not able to sign in to fetch data further. If anyone of you have ever faced such situation please help me out here. This small obstacle is pretty maddening.

Thank you everyone.

Raptor
  • 53,206
  • 45
  • 230
  • 366
rohitpaniker
  • 695
  • 1
  • 7
  • 25
  • try the google sample for g+ login. The code remains the same. all you need to do is generate google-services.json. Also retrieving email of the user requires permission at run time in marshmallow – Raghunandan Jan 26 '16 at 07:08
  • @Raghunandan Thank you for your reply, i have already used the sample and everything works fine, went to developer console to generate common google-services.json for G+ Signin and GCM and placed it within /app directory and when i test it on my device and try to sign in, screen fades in and fades out in few seconds and it still gives handleSignInResult:false in LogCat whereas i copied the code from sample as it is and just modified enough as per my requirement and followed all the necessary steps provided in the Google+ Sign In integration tutorial. – rohitpaniker Jan 26 '16 at 07:38
  • i din't understand this *generate common google-services.json for G+*. You need to generate the file again based on app name and package name. – Raghunandan Jan 26 '16 at 07:47
  • @Raghunandan I meant, I am using 2 APIs of Google, 1) GCM API and 2) G+ Sign In API. So earlier i had only requirement of GCM Push Notification which is working great. Now as per new requirement i want to integrate G+ Sign In to the same app and again generated a new google-services.json which has both configuration for GCM as well as G+ Sign In now, downloaded it, pasted the newly downloaded google-services.json to app/ directory. Code runs fine, app works without crashing but when i click on "G+ sign in" the app throws in the LogCat: D/SignInActivity: handleSignInResult:false – rohitpaniker Jan 26 '16 at 08:13
  • I had the same problem and the solution was silly. I did not know that I turned off the internet connection and was trying to debug the application. The error was very misleading and unclear as i just got the error code 12501 and nothing regarding no network connection. Hope it helps someone else. – BlackCursor Jan 22 '17 at 01:08

8 Answers8

8

Are you using Plus.API or Auth.GOOGLE_SIGN_IN_API? The latter is the latest revamped one. Check it out here: https://developers.google.com/identity/sign-in/android/sign-in


If you are using Auth.GOOGLE_SIGN_IN_API:

In onActivityResult, use code similar to below and you can get a status code, which is defined by GoogleSignInStatusCodes: https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInStatusCodes

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        int statusCode = result.getStatus().getStatusCode();
    }
}

The most common issue is missing the right OAuth2 client registration. (Unfortunately, for now, the status code is INTERNAL_ERROR 8, which is not helpful. ) E.g. Take a look at this thread: Occured an INTERNAL_ERROR when requestEmail from GoogleSignInOptions Android

Community
  • 1
  • 1
Isabella Chen
  • 2,421
  • 13
  • 25
  • 1
    Hi @Isabella, i am using the latter and as per the documentation i've already followed them step by step and implemented everything. Now when i try to login on my device, the app asks to choose account and when i select the account for login, the device screen dims for few seconds trying to log in and then nothing happens. When i check LogCat i just get the same error: `E/GMPM: getGoogleAppId failed with status: 10` `E/GMPM: Uploading is not possible. App measurement disabled.` `D/SignInActivity: handleSignInResult:false` – rohitpaniker Feb 02 '16 at 08:41
  • Updated the answer inline – Isabella Chen Feb 12 '16 at 16:14
  • For me everything is working fine except new account, when I add new google account nothing will happened... in success I can see semitransparent overlay for sometimes and it automatically exit after that if I click the sign in button agian this time auto sign in happen... my question why it's not able to resume the operations after adding new account – Bytecode Jul 20 '16 at 19:07
  • @Bytecode Could you paste your GoogleSignInOptions? Adding new account is supported scenario and I cannot repro. – Isabella Chen Jul 22 '16 at 05:02
  • @IsabellaChen GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .requestIdToken("xxxxx") .build(); – Bytecode Jul 23 '16 at 12:55
  • @Kenji 12501 means SIGN_IN_CANCELLED. If user didn't finish sign-in flow (e.g. click away from account picker), then 12501 will be returned. If it's from your testing and you did go through the sign-in process, please let me know how to repro. – Isabella Chen Jan 03 '17 at 20:47
  • I am having the problem when new account is added. For the first time i only get email and token, apart from that all the fields are null like name. Any solution ? – Gautam Mar 31 '17 at 06:28
  • @Bytecode Were you able to find a fix for this? I'm getting the same problem with only new accounts, otherwise works great. Which leads me to believe it isn't a SHA1 key issue. Any help with how you fixed this would be so greatly appreciated!!! – Jared Nelson Apr 05 '18 at 14:53
  • @Gautam, for new account, yeah, it takes some time to sync down the name data. As a work-around, you can always requestIdToke() & requestProfile() and the name will be retrieved from server instead. – Isabella Chen Apr 05 '18 at 20:42
  • @Jared, see above – Isabella Chen Apr 05 '18 at 20:42
6

Please insure that you had applied SHA-1 debug key in the google-services.json file creation.

lRadha
  • 641
  • 6
  • 16
4

As Sudhanshu Gaur pointed out in this post, try first generate a signed apk using the same key you used to create your json configuration file. Then install it on your device and see whether it works. The reason is Android Studio does not sign your apk when you click "run".
I was stuck on exactly the same problem and this fix worked fine for me.

Community
  • 1
  • 1
Jason Liu
  • 61
  • 5
  • Ahan, true, finding it very confusing to integrate the login. But i guess i will somehow eventually manage to integrate. The problem i face is when i have to integrate both FB Login and G+ Login on one form. Maybe it has to do with me being an intermediate android programmer. Thank you for your efforts though to point out :) – rohitpaniker Jun 03 '16 at 08:15
3

If you are adding all the SHA-1 Finger prints in firebase still you are getting error.then (I was facing this problem. after this steps it's resolved.)Try this steps:

1.Go to Google Console API credentials Page.

2.Click the credentials in the Left tab.

3.Already two default Android and Web OAuth client Id will be present. You have to create One Android Client and One Web 2.0 Client.

4.Go to Firebase.In project setting ,download google-services.json and paste in app folder.

(Everything is fine but still you are cannot signin google means maybe OAuth problem. so make sure to create Android and Web client ID.Finally in credential page you have 2 Android Client and Two Web client Id.)

Gopal
  • 580
  • 8
  • 26
  • 1
    In my case I was updating a project, and for some reason the SHA-1 changed. Then I added the new one to the allowed list in the Firebase console, and it is working. Thanks. – JCarlosR Sep 11 '18 at 00:15
1

you need to provide the SHA-1 hash of your signing certificate on your app

example:

Registered SHA-1s:

CF:4A:A1:0A:BC:84:F2:31:28:C3:BA:A7:A3:A2:36:10:5F:1D:3E:CB and download the config file you created.. and replace to *yourproject/app/google-service.json

//Get google-service.json file tutorial https://developers.google.com/identity/sign-in/android/start-integrating

//how to get SHA-1 https://developers.google.com/android/guides/client-auth

Exel Staderlin
  • 535
  • 7
  • 10
0

Please check your SHA-1 added key is debug or release, based on your key its work relatively on it. I have get same issue latte i understand that i have used release SHA-1 and i am testing on debug then it will get false result. Thanks

Sagar Pithiya
  • 56
  • 1
  • 1
  • 4
0

Generate the debug key first:

keytool -exportcert -list -v \
-alias androiddebugkey -keystore ~/.android/debug.keystore

Then paste the SHA1 to the Firebase or Google project Settings in the fingerprint section.

Taras Vovkovych
  • 4,062
  • 2
  • 16
  • 21
0
package com.google.samples.quickstart.signin;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;

/**
 * Activity to demonstrate basic retrieval of the Google user's ID, email address, and basic
 * profile.
 */
public class SignInActivity extends AppCompatActivity implements
        View.OnClickListener {

    private static final String TAG = "SignInActivity";
    private static final int RC_SIGN_IN = 9001;

    private GoogleSignInClient mGoogleSignInClient;
    private TextView mStatusTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_DEMO);

        // Views
        mStatusTextView = findViewById(R.id.status);

        // Button listeners
        findViewById(R.id.sign_in_button).setOnClickListener(this);
        findViewById(R.id.sign_out_button).setOnClickListener(this);
        findViewById(R.id.disconnect_button).setOnClickListener(this);

        // [START configure_signin]
        // Configure sign-in to request the user's ID, email address, and basic
        // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();
        // [END configure_signin]
        // [START build_client]
        // Build a GoogleSignInClient with the options specified by gso.
        mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
        // [END build_client]

        // [START customize_button]
        // Set the dimensions of the sign-in button.
        SignInButton signInButton = findViewById(R.id.sign_in_button);
        signInButton.setSize(SignInButton.SIZE_STANDARD);
        signInButton.setColorScheme(SignInButton.COLOR_LIGHT);
        // [END customize_button]
    }

    @Override
    public void onStart() {
        super.onStart();

        // [START on_start_sign_in]
        // Check for existing Google Sign In account, if the user is already signed in
        // the GoogleSignInAccount will be non-null.
        GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
        updateUI(account);
        // [END on_start_sign_in]
    }

    // [START onActivityResult]
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
        if (requestCode == RC_SIGN_IN) {
            // The Task returned from this call is always completed, no need to attach
            // a listener.
            Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
            handleSignInResult(task);
        }
    }
    // [END onActivityResult]

    // [START handleSignInResult]
    private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
        try {
            GoogleSignInAccount account = completedTask.getResult(ApiException.class);

            // Signed in successfully, show authenticated UI.
            updateUI(account);
        } catch (ApiException e) {
            // The ApiException status code indicates the detailed failure reason.
            // Please refer to the GoogleSignInStatusCodes class reference for more information.
            Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
            updateUI(null);
        }
    }
    // [END handleSignInResult]

    // [START signIn]
    private void signIn() {

        Intent signInIntent = mGoogleSignInClient.getSignInIntent();
        startActivityForResult(signInIntent, RC_SIGN_IN);

       /* Intent sign = mGoogleSignInClient.getSignInIntent ();
        startActivityForResult ( sign, RC_SIGN_IN );*/

    }
    // [END signIn]

    // [START signOut]
    private void signOut() {
        mGoogleSignInClient.signOut()
                .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                    @Override
                    public void onComplete(@NonNull Task<Void> task) {
                        // [START_EXCLUDE]
                        updateUI(null);
                        // [END_EXCLUDE]
                    }
                });
    }
    // [END signOut]

    // [START revokeAccess]
    private void revokeAccess() {
        mGoogleSignInClient.revokeAccess()
                .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                    @Override
                    public void onComplete(@NonNull Task<Void> task) {
                        // [START_EXCLUDE]
                        updateUI(null);
                        // [END_EXCLUDE]
                    }
                });
    }
    // [END revokeAccess]

    private void updateUI(@Nullable GoogleSignInAccount account) {
        if (account != null) {
            mStatusTextView.setText(getString(R.string.signed_in_fmt, account.getDisplayName()));

            findViewById(R.id.sign_in_button).setVisibility(View.GONE);
            findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
        } else {
            mStatusTextView.setText(R.string.signed_out);

            findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
            findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.sign_in_button:
                signIn();
                break;
            case R.id.sign_out_button:
                signOut();
                break;
            case R.id.disconnect_button:
                revokeAccess();
                break;
        }
    }
 }
Good We
  • 1
  • 1