1

I'm building a Flutter app with firebase_auth and google_sign_in.

Everything was working well for a while and all of my existing users on the released product have not experienced any problems, but a while back I started getting reports that new users couldn't log in. I didn't think much of it until the reports started to accumulate. I found that they were getting the error posted in the title. I spent a ton of time investigating...

I've gone through all of the other StackOverflow entries for this issue:

  1. Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  2. PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  3. Exception has occurred. PlatformException (PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null))
  4. Flutter: Firebase: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  5. Flutter: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  6. Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  7. com.google.android.gms.common.api.ApiException: 10:
  8. com.google.android.gms.common.api.ApiException: 10
  9. How to correct " com.google.android.gms.common.api.ApiException: 10: "
  10. Firebase Google Signin error: com.google.android.gms.common.api.ApiException: 10
  11. Google sign in failed com.google.android.gms.common.api.ApiException: 10:
  12. Why do I get com.google.android.gms.common.api.ApiException: 10:?
  13. Error with Google_sign_in plugin in flutter

And I've tried all of the solutions:

  • Generated debug key
  • Entered SHA1 debug key on the Firebase site
  • Verified that my email was entered on the Firebase site.
  • Downloaded the google-services.json file and put it in the android/app/ directory
  • Built the flutter app using flutter build appbundle --debug
  • PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

So I also tried:

  • With just the release key on the Firebase site and built with flutter build appbundle --release
  • With both the release key and the debug key
  • With the SHA256 for each combination above
  • With each of these combinations, I was sure to flutter clean and replace the google-services.json file with the updated one

  • Verified that android/build.gradle and android/app/build.gradle were configured properly

  • Verified that "Google" was enabled as a "Sign-in Method" was enabled on the Firebase site
  • I even filled out the OAuth consent screen with my app name, logo, email, homepage, privacy, & terms of service links and saved

Here are the versions that I'm running with:

  google_sign_in: ^4.0.7
  firebase_auth: ^0.14.0+5

Relevant portion of the android/app/build.gradle:

dependencies {
    implementation "androidx.appcompat:appcompat:1.1.0-alpha01"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation "com.google.android.gms:play-services-auth:16.0.1"
    implementation "com.google.android.gms:play-services-identity:16.0.0"
    implementation "com.android.support:support-v4:28.0"
}

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

Relevant portion of the android/build.gradle:

buildscript {
   ext.kotlin_version = '1.2.71'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

Flutter doctor output:

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.2, on Linux, locale en_US.UTF-8)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0-rc1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.38.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

All testing was done on multiple devices using the Robo test lab on Firebase (only to see if the login was successful, not to test the UI).


TLDR; In the end, I finally figured out that it works if I build the apk using flutter build apk (as opposed to an appbundle). Then I realized that the problem started about the same time that flutter started recommending that I generate appbundles instead of apks.

Has anyone been able to sign in a BRAND NEW USER with flutter using google_sign_in when generating an appbundle? (Keep in mind that existing users who previously signed in to an earlier version of the app work without issue.)

6
  • Hi, I have exactly the same issue on Mac but the app works on windows. Whats OS are you using? and java version? I see that we have identically app configuration... If I fix it, I'll let you know! Let me know please if you fix it please Oct 2, 2019 at 11:46
  • @MauroSebastianVolpeParedes I've tried building on both Linux Mint and Windows 10. Both have the same behavior (apk works, abb errors). jdk1.8.0_152 on Windows.
    – Simpler
    Oct 2, 2019 at 12:53
  • Did you enroll in Play Signing from the start or did you have an existing app that you enrolled later?
    – Pierre
    Nov 1, 2019 at 18:59
  • @Pierre, It's been a while, but I think this was an existing app in the Play Store that I enrolled in Play Signing after some time. How is that relevant?
    – Simpler
    Nov 1, 2019 at 19:04
  • Trying to see if this could be related to signature authentication, but probably not. Is there any common pattern among the devices that can't log in?
    – Pierre
    Nov 2, 2019 at 9:33

1 Answer 1

2

If you are using Internal App Sharing to test Flutter builds on actual Android devices (like I am), there is another App Signing certificate fingerprint you need to add.

On the left navigation of Google Play Console go to: Developer Tools -> Internal App Sharing

Select the App Certificate tab. Should look something like this:

Google Play - Internal App Sharing - Certificate

Copy the SHA1 key and add it to the Firebase Console -> Project Settings -> [your Android app] -> SHA certificate fingerprints (use the button to Add fingerprint)

Download your updated google-services.json and update/add it in your android/app folder of your project.

This works with new users and existing users. I built the an appbundle (not APK) using flutter build appbundle

This isn't documented anywhere by Google and I have not seen this solution elsewhere in the Flutter community. I came across this solution while poking around in the Google Play console after trying all of your referenced links and several others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.