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:
- Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
- PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
- Exception has occurred. PlatformException (PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null))
- Flutter: Firebase: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
- Flutter: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
- Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
- com.google.android.gms.common.api.ApiException: 10:
- com.google.android.gms.common.api.ApiException: 10
- How to correct " com.google.android.gms.common.api.ApiException: 10: "
- Firebase Google Signin error: com.google.android.gms.common.api.ApiException: 10
- Google sign in failed com.google.android.gms.common.api.ApiException: 10:
- Why do I get com.google.android.gms.common.api.ApiException: 10:?
- 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 oneVerified that
android/build.gradle
andandroid/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.)