2
votes

I'm trying to add google sign-in to my android app. Everything works fine on debug build. But when I push the apk for internal testing on Google Play it throws Google SignIn API Exception 10. Should I add anything extra to my console?

So far I've done the following things,

  1. Created new firebase project

  2. Added SHA-1 to firebase console.

  3. Downloaded google-services.json from firebase and copied to app folder.

  4. On my https://console.cloud.google.com/apis/credentials page everything is automatically filled by firebase. So, I didn’t do anything there.

  5. Add all required libraries to android project

    protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

            setContentView(R.layout.activity_login);
            SignInButton signInButton = findViewById(R.id.sign_in_button);
            signInButton.setSize(SignInButton.SIZE_WIDE);
    
            GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(getString(R.string.default_web_client_id))
                    .requestEmail()
                    .build();
    mGoogleSignInClient = GoogleSignIn.getClient(this, so);
    }
    

    @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);
            Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
            try {
                // Google Sign In was successful, authenticate with Firebase
                GoogleSignInAccount account = task.getResult(ApiException.class);
                Log.e(TAG, "firebaseAuthWithGoogle:" + account.getId());
                //firebaseAuthWithGoogle(account.getIdToken());
            } catch (ApiException e) {
                // Google Sign In failed, update UI appropriately
                Log.e(TAG, "Google sign in failed", e);
            }
            handleSignInResult(task);
        }
    }
    

HandleSignInResult;

 private void handleSignInResult(Task<GoogleSignInAccount> 
   completedTask) {
                String personName = "", personEmail = "", aid = "";
                 Uri personPhoto = Uri.parse("");
                // GoogleSignInAccount acct = 
    GoogleSignIn.getLastSignedInAccount(this);
                  GoogleSignInAccount acct = completedTask.getResult();
                  if (acct != null) {
                     personName = acct.getDisplayName();
                     personEmail = acct.getEmail();
                     personPhoto = acct.getPhotoUrl();
                     aid = acct.getId();
                     Log.e("ID_TOKEN", acct.getIdToken() + "");
                 } 
      }
1
Have you added the release SHA-1 to your console? - dennisrufigill
Yes. Using the debug.keystore - Sujith Manjavana
Not sure if this is the cause, but if you have Google Play Signing enabled, you might need to add the SHA-1 that you can find in the Google Play console under Release -> Setup -> App integrity. Worth a try. - lasagnakid77
@lasagnakid77 should I replace my debug.keystore SHA-1 with this one from google play console? - Sujith Manjavana

1 Answers

1
votes

It's now working after I added the SHA-1 from Google Play console under Release -> Setup -> App integrity as @lasagnakid77 mentioned in his comment.