Android Google SignIn not working in debug mode: GoogleSignInResult is false

后端 未结 6 948
我在风中等你
我在风中等你 2020-12-17 08:36

I have been following this tutorial to get Google SignOn going: https://developers.google.com/identity/sign-in/android/start-integrating

When I run my application lo

相关标签:
6条回答
  • 2020-12-17 09:17

    I had the same problem and it was due to

    apply plugin: 'com.google.gms.google-services'
    

    not being at the bottom of the app build.gradle.

    Figured it out by looking at the Gradle Console. No errors were raised.

    0 讨论(0)
  • 2020-12-17 09:25

    Reason for the can be: - You might be using an unsigned apk to test you app.

    Go to Build->Generate Signed APK -> sign it with the key you used to get your SHA1 Fingerprint to make clientID on google developer console

    Run app-debug.apk and its done!!

    0 讨论(0)
  • 2020-12-17 09:26

    EDITED

    The answer is derived from this, as it will applicable for this problem also

    I am Enclosing the Answer here

    The problem is due to the Signing Certificate and the SHA-1 certificate fingerprint. Add the following SHA-1 certificates into your googleApi credentials. there are 2 cases

    1.If you are running in debug mode add the SHA-1 fingerprint generated by the following

    "C:\Program Files\Java\jre1.8.0_101\bin\keytool" -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
    

    2.If you have configured Signing Config then use SHA-1 fingerprint generated by following

    "C:\Program Files\Java\jre1.8.0_101\bin\keytool" -list -v -keystore "[youKeyPath]\youKey.jks"
    

    I recommend you to add both the SHA-1 fingerprints in your googleApi credentials

    0 讨论(0)
  • 2020-12-17 09:30

    In addition to the above answers, I came across one case where the problem was caused due to the configuration was mismatched to the google-services.json file:

    It is also possible that the clientId was specifically assigned in the GoogleSignInOptions Builder as shown below:

        String serverClientId = "xxxxx-yyyy.apps.googleusercontent.com";
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .requestIdToken(serverClientId)
                .build();
    

    If this is the case, it is possible to remove the reference to the serverClientId and the requestIdToken call as shown below:

        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();
    

    This would then rely on the google-services.json as opposed to the hard-coded value during configuration.

    I hope it saves someone else the trouble that I had trying to diagnose the fault with my project.

    0 讨论(0)
  • 2020-12-17 09:37

    You are probably missing dev console registration. It's very common developers will have multiple signing cert configuration: debug key store, test environment signing cert, production signing cert. signing cert SHA1 + package name uniquely identifies an Android client and needs to be registered individually in dev console.

    See below blogpost to understand more about OAuth clients registration:

    http://android-developers.blogspot.com/2016/03/registering-oauth-clients-for-google.html

    Or see this post: Test google signin on Android in development phase

    0 讨论(0)
  • 2020-12-17 09:42

    As per this you need 3 SHA1 keys in Firebase project settings

    In most of the case, the problem is the third key.

    1. The debug key

      keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

    2. The release key

      keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64

    3. Google Play App signing key

      https://play.google.com/apps/publish/

      in your app's Release management > App signing > App signing certificate

      it's SHA1 key

    You need THREE keys to figure out ONE Google SignIn.

    0 讨论(0)
提交回复
热议问题