flutterdartgoogle-signin

google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)


I have a Flutter app with Google sign-in. I have added the SHA1 and SHA256 keys to Firebase, from a computer. and everything is alright from that computer.

but when I run the app from other computers I get this error

PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

I have added also added support email as well. how can I fix this?


Solution

  • This happens because Firebase(and others) need to have the sha for each key registered. By default, android studio creates a debug signing key. When you collaborate with other people, you can create a key(or copy the one generated by AS) and set it up for the project.

    1. run ./gradlew signingReport
        ./gradlew signingReport
        
        > Task :app:signingReport
        Variant: debug
        Config: debug
        Store: ~/.android/debug.keystore
        Alias: AndroidDebugKey
        MD5: A5:88:41:04:8D:06:71:6D:FE:33:76:87:AC:AD:19:23
        SHA1: A7:89:E5:05:C8:17:A1:22:EA:90:6E:A6:EA:A3:D4:8B:3A:30:AB:18
        SHA-256: 05:A2:2C:35:EE:F2:51:23:72:4D:72:67:A5:6C:8C:58:22:2A:00:D6:DB:F6:45:D5:C1:82:D2:80:A4:69:A8:FE
        Valid until: Wednesday, August 10, 2044
    
    1. go to the path: Store: ~/.android/debug.keystore
    2. copy debug.keystore in your root project
    3. go to app/build.gradle
    4. add this in the android { ... } section
    signingConfigs {
            debug {
                storeFile file("../debug.keystore")
                storePassword "android"
                keyAlias "androiddebugkey"
                keyPassword "android"
            }
        }
    

    push your changes and now everybody will use the same debug key and you don't need to register different SHA for every developer.

    This is different than the release key, which you should never push on Git.