PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) when using Flutter to build an appbundle

南笙酒味 提交于 2019-12-11 14:29:43

问题


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.)


回答1:


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.



来源:https://stackoverflow.com/questions/58194425/platformexceptionsign-in-failed-com-google-android-gms-common-api-apiexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!