I followed this tutorial and in this part of the code:
@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);
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthWithGoogle(account);
} else {
// Google Sign In failed
Log.e(TAG, "Google Sign In failed.");
Toast.makeText(SignInActivity.this,"Google Sign In Failed.",Toast.LENGTH_SHORT).show();
}
}
}
I am getting a google sign in failed. I do not know what is wrong how to fix?
I actually got in working when I tried running app-released.apk instead of running in directly on my phone.
Perhaps you messed up/haven't configured your debug certificate (might happen if you switch to another development machine with different keystore set). Make sure you have added the SHA1 certificate fingerprint in the Firebase Console Settings section of your project, as described here: https://firebase.google.com/docs/auth/android/google-signin#before_you_begin
Google sign-in is automatically configured on your connected iOS and web apps. To set up Google sign-in for your Android apps, you need to add the SHA1 fingerprint for each app on your Project Settings.
See this page for information on using keytool to get the SHA hash of your signing certificate
https://developers.google.com/android/guides/client-auth
Go to Project - Settings - General to add the fingerprint.
To get the SHA1 debug fingerprint (if you are debugging you only need this one):
keytool.exe -list -alias androiddebugkey -keystore C:\Users\<username>\.android\debug.keystore -storepass android -keypass android
To get the SHA1 release fingerprint:
keytool -exportcert -list -v -alias <MYKEYNAME> -keystore C:\mykeylocation\keystore.jks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With