264

The dialog (Google form) for the credentials is opened successfully, but after I fill my credentials I'm getting this error. I followed the instructions from here. Created a Firebase project, enabled the Google Drive API (that's what I need for now) from the Google APIs Console.

The code throwing the exception:

final GoogleSignIn _googleSignIn = GoogleSignIn(
  scopes: [
    'https://www.googleapis.com/auth/drive',
  ],
);

await _googleSignIn.signIn();

That's the stack trace:

E/flutter ( 5068): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter ( 5068): PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
E/flutter ( 5068): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter ( 5068): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292:18)
E/flutter ( 5068): <asynchronous suspension>
E/flutter ( 5068): #2      GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:226:58)
E/flutter ( 5068): <asynchronous suspension>
E/flutter ( 5068): #3      GoogleSignIn._addMethodCall (package:google_sign_in/google_sign_in.dart:268:20)
E/flutter ( 5068): #4      GoogleSignIn.signIn (package:google_sign_in/google_sign_in.dart:339:48)
E/flutter ( 5068): #5      ThatsMyComponentState.theSignInFuction.<anonymous closure> (package:my_app/widgets/my_file.dart:666:45)
E/flutter ( 5068): <asynchronous suspension>
E/flutter ( 5068): #6      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter ( 5068): #7      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
E/flutter ( 5068): #8      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter ( 5068): #9      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter ( 5068): #10     TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
E/flutter ( 5068): #11     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter ( 5068): #12     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:184:20)
E/flutter ( 5068): #13     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
E/flutter ( 5068): #14     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
E/flutter ( 5068): #15     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter ( 5068): #16     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter ( 5068): #17     _invoke1 (dart:ui/hooks.dart:168:13)
E/flutter ( 5068): #18     _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)

The version of the google_sign_in plugin is 4.0.0.

That's the output of flutter doctot -v:

[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.17763.253], locale en-US)
• Flutter version 1.0.0 at C:\src\flutter-0.7.3\flutter
• Framework revision 5391447fae (10 weeks ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at C:\Users\myuser\AppData\Local\Android\Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = C:\Users\myuser\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.

[√] Android Studio (version 3.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 32.0.1
• Dart plugin version 182.5124
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[!] IntelliJ IDEA Community Edition (version 2018.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.6
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
  https://flutter.io/intellij-setup/#installing-the-plugins

[!] VS Code, 64-bit edition (version 1.30.2)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension not installed; install from
  https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)

! Doctor found issues in 2 categories.

Any help will be much appreciated. Thanks!

TSR
  • 17,242
  • 27
  • 93
  • 197
Boyan Bozhidarov
  • 2,675
  • 2
  • 7
  • 6
  • 2
    To all: pay attention to the exception code `ApiException: 10` and refer to the docs first - https://developers.google.com/android/reference/com/google/android/gms/common/api/CommonStatusCodes Make sure you're fixing the right issue. For example code 7 would just mean 'no internet connection'. – Kirill Karmazin Feb 14 '20 at 13:52
  • Run ./gradlew signingReport, it's under the app Android folder. Add SHA1 in google Firebase Google Sign in configuration. https://developers.google.com/android/guides/client-auth . You will need an SHA1 for each computer you work on. – live-love Jun 27 '20 at 23:44
  • @KirillKarmazin any idea what 12500 is? E/flutter (23795): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null) – raiton Jul 02 '20 at 13:49

51 Answers51

371

I run into the same issue just now. This might happens if you are running on debug and you did not register a SHA fingerprint in firebase. I solved it by generating a debug.keystore by running:
keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

and registering it inside the app on Firebase. Don't forget to download the new google-services.json after that.

See also this.

enter image description here

Edit If you are not able to use authenticate in release mode try the following:

-Add the SHA certificate fingerprints of the release key.

keytool -exportcert -list -v \ -alias <your-key-name> -keystore <path-to-production-keystore>

For more details on that see here on the section "get release certificate" https://developers.google.com/android/guides/client-auth

If your authentication is still not working, probably it is because you downloaded the app from Playstore and you enabled the "App Signing by Google Play Feature" Then for this case, go to play store publish console and go to app signing under release management. There you will find the SHA certificate fingerprint to register in Firebase console.

enter image description here

Sam Hiatt
  • 385
  • 4
  • 8
TSR
  • 17,242
  • 27
  • 93
  • 197
  • 43
    Thanks for this. This helped. Worthwhile noting that both the SHA1 and SHA256 keys had to be added for the auth to work – Srini Feb 26 '19 at 00:28
  • 2
    @TSR this worked but I didn't have to download a new google-services.json. – Darren Cole Mar 03 '19 at 17:47
  • 7
    FYI, I had the same error even after configuring my sha fingerprints. Turns out i also had to add a support email address per https://github.com/flutter/flutter/issues/25909#issuecomment-497378619 . – Michael Nelson Jun 03 '19 at 13:17
  • @MichaelNelson this was my problem, too – otto Jun 10 '19 at 17:13
  • Where do you find ? How do you create this file? – live-love Jun 27 '20 at 23:25
  • Only SHA1 is needed. – live-love Jun 27 '20 at 23:28
  • 8
    your edit linking to "If you've published your app using Play App Signing, a requirement when using Android App Bundle, you can get your SHA-1 from the Google Play Console on the Release > Setup > App Integrity page" saved me! thank you! – adrianvintu Sep 23 '21 at 19:35
  • for additional support, refer [https://stackoverflow.com/a/56091158/10505343](https://stackoverflow.com/a/56091158/10505343) – Wimukthi Rajapaksha Oct 01 '21 at 20:55
  • awesome. this was exactly the problem i was going through. Thank you. – Suhas TJ Dec 24 '21 at 12:11
  • I ran into this just now and want to EMPHASIS that having *just* SHA-256 in your Firebase project config will get you this error, you MUST also have the SHA-1 fingerprint despite the android cli tool `keytool` warning that SHA-1 is a security risk & will be disabled in the future. – Maks Jul 26 '22 at 01:00
  • Thank you, you saved me, I forgot to put SHA1 & SHA256 for Google Play Console in Firebase Keys. – AMMAR ELHAMDO Sep 14 '22 at 07:23
  • When I hit this error it was caused by not having google play installed on the phone emulator. – Subtubes Nov 17 '22 at 20:10
144

I spent ages trying to fix this.

1. Open grade.properties This file is found under: {{YOUR PROJECT}}/android/gradle.properties

enter image description here

2. Add the following argument to 'org.gradle.jvmargs' as shown in the screenshot.

-XX:MaxHeapSize=256m -Xmx256m

enter image description here

3. Right click on 'gradlew' and go to 'Open in Terminal' This file is found under {{YOUR PROJECT}}/android/gradlew

enter image description here

4. Type in the following command.

gradlew signingReport

If did not work first try second command:

./gradlew signingReport

5. Wait for the compilation to finish and your SHA keys should be printed out for you.

enter image description here

Use these keys to authenticate your app in https://console.firebase.google.com/

Ramis
  • 13,985
  • 7
  • 81
  • 100
KylianMbappe
  • 1,896
  • 2
  • 15
  • 25
103

The following solution works in flutter project:

Step 1: Generate SHA1 and SHA256 keys.
Step 2: Add both the SHA1 and SHA256 to firebase. (in you app settings)
Step 3: Download google-services.json to android/app in your project folder.
Step 4: In your terminal run the command flutter clean .
Step 5: Run your flutter app.

For more information visit:
https://developers.google.com/android/guides/client-auth
https://firebase.google.com/docs/flutter/setup

Rabi Roshan
  • 1,268
  • 1
  • 11
  • 9
101

Open the Firebase console and click on the settings icon.

You will see the list of the apps connected to your Firebase project

For Android

  1. Open terminal inside your flutter project
  2. cd android
  3. ./gradlew signingReport or gradlew signingReport
  4. Paste your SHA1 key
  5. Download and replace the google-services.json
  6. flutter clean

IOS:

  1. Configure your Firebase project
  2. Select IOS
  3. Enter your Bundle ID
  4. Download credetials
  5. Download and replace GoogleService-info.plist

Add this to your info.plist

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>**INSERT HERE YOUR RESERVED_CLIENT_ID FROM GoogleService-Info.plist**</string>
        </array>
    </dict>
</array>
Matteo Antolini
  • 2,560
  • 2
  • 19
  • 30
  • 4
    gradlew signingReport helps me a lot, because I first I just use the wrong keystore. And with that command, you get definitely the right one. – BHuelse Dec 13 '19 at 09:52
  • Thank you, I was struggling all the day to find a solution , I gave you up-vote :) – Malek Tubaisaht Mar 03 '23 at 19:08
41

When I came across this problem, I tried all other solutions described in this post. None of these worked. Eventually I figured it out: In my situation I had to make sure to have my "support email" set.

Public Setting Support Email

Johan Witters
  • 1,529
  • 11
  • 23
32

For me I didn't need to add extra SHAs, I realized I didn't enable the Google Sign-in method in the Authentication tab in Firebase console

Enabling google sign-in method in Firebase console

Rahul Suresh
  • 184
  • 1
  • 14
Vidral Bonvi
  • 509
  • 4
  • 6
21

Additional steps you might have to take in order for google_sign_in to work:

][2]

  • If you could run Google Sign In during debug but NOT in release, there is a high chance that you did not add your release key's SHA1 and SHA256 to firebase. To get the release key's SHAs, use keytool -list -v -keystore ~/key.jks -alias key

console You should end up with total of at least 6 SHA credentials: 2 from the debug key, 2 from Google Play linking, and 2 from the release key. Note that you do not need to redownload the google-services.json file after adding the release SHA credentials to firebase.

Firebase

# Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }

# GooglePlay Services
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep class com.google.common.** { *; }
-dontwarn com.google.common.**
function1983
  • 971
  • 11
  • 14
19

If your released app is not working properly, and you are using Google Play Signing, Copy the SHA from your play store account, the one from your local key will not work enter image description here

Za101
  • 451
  • 3
  • 6
  • 1
    Thank you! This is the missing essential step to putting my app in production that had me trial-and-erroring for hours. Other solutions here were only good for building debug versions. – user2897738 Jun 20 '21 at 08:43
  • I have this issue, my app that has been on the Google Play App Store suddenly not working, but unfortunately the 'App Signing' section is no longer available. – Alexa289 May 31 '22 at 07:32
  • ahhh I got it, it is now in the 'App Integrity' section. and then copy that SHA-1 certificate fingerprint to Firebase Console (project settings -> general -> scroll down until you see your Android app) – Alexa289 May 31 '22 at 07:44
14

I found a solution for the error com.google.android.gms.common.api.ApiException: 10: I solved it by adding more keys to the firebase. initially I thought it was stupid and useless, then in the end it turned out to be the solution (I added up to 10 SHA, don't worry if that's a lot).

  1. Where did I find all these keys?

I found all these keys by entering the android folder and typing the command ./gradlew signingReport (I use linux, it also works on mac. For windows the command is gradlew signingReport)

  1. After that?

After that, he printed out a very long list of keys in my terminal, and I took all the ones that were different, that were at the top of the list.

Note: you will get all the keys (both debug and release) of each package of the app, but rest assured that all those of the packages are the same and only for debugging (so you will have to take these same keys only once)

  1. Finally

Once you have all the app keys, go to your project's Firebase settings, scroll down and add any keys you found. After that, you will need to download the google-services.json file again and run a flutter clean in your project's local folder on your computer.

Now you can build your app and see if it works!

I hope this could help someone.

Marco Zoratti
  • 181
  • 1
  • 3
9

"Flutter clean" its the piece that everybody is missing after register the SHA1 in Firebase Console!

Roger Gusmao
  • 3,788
  • 1
  • 20
  • 17
8

You have missed configuration step enable google login on firebase.

Google sign-in is automatically configured on your connected iOS and web apps. To set up Google sign-in for your Android apps, you need to add the SHA1 fingerprint for each app on your Project Settings.

Just complete these enough steps below

  1. Enable Google Auth Method
  2. Configure certificate fingerprints in your current project at project-level setting. How to Generate certificate.
  3. Select email for Project support email
  4. Download google-service.json into your project.
  5. Run flutter clean
  6. start flutter run

image

Sen Sokha
  • 1,784
  • 16
  • 16
8

The answer that given early are right. None of them are false. But if you still face the error PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null). One thing that your should check is your OAuth 2.0 Client IDs

enter image description here

  1. Go to : https://console.cloud.google.com/apis/credentials
  2. Select your project on the top left screen
  3. Create Client ID base on your platform (iOS or Android)
  4. Just follow the next steps

Once you successfully generate the client ID, then your application will works as expected.

--- Note ---

But first, make sure you have regitered your SHA-1, package id email support and has been download the google service json from your firebase console project.

Bali Codes
  • 581
  • 1
  • 5
  • 8
6

One reason that you might be experiencing this error is if you did not fill out google's OAuth consent form. This is a new change to Firebase.

Here are the steps you need to follow to fill out the consent form for your app:

  1. Navigate to the google api console (currently at https://console.developers.google.com), make sure you are logged into your account which your firebase project is created under.
  2. Select your project from the "select a project" dropdown in top left of the developer console.
  3. In the left hand pane travel to "credentials" and then switch to the "OAuth consent screen".
  4. Under "Application name" enter your application's public name
  5. Under "Application logo" upload a local image file of your application
  6. Under "Support email" enter the same support email listed in your firebase application.

Your screen should now look like this example by step 6

  1. Scroll down and fill out the "Application Homepage Link", "Application Privacy Policy Link", and "Application Terms of Service Link" by adding http:// before the authorized domain which your firebase app lives at.

Here is a highlighted example of how these regions should be filled out in step 7

  1. Click Save

These steps worked for me! While the link may not still exist, I'd like to reference the source of this solution here

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Ben Elliott
  • 129
  • 2
  • 5
  • Is it actually an answer to the question? – Bulat Jul 25 '19 at 05:12
  • Thank you for the feedback. I tried to update my answer to be more specific--please let me know if it is now appropriate--and if not, how I can improve it. – Ben Elliott Jul 25 '19 at 09:00
  • 1
    Do you need to "Submit for Verification", or just "Save"? – Simpler Sep 27 '19 at 18:25
  • 4
    If you arrived here, for your mental sanity, do no add a logo to the oauth screen consent. It's not needed and it triggers a verification. – alex Mar 17 '21 at 09:23
5

make sure you have added

 dependencies {
    classpath 'com.google.gms:google-services:4.2.0'
}

in android/build.gradle and

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

in android/app/build.gradle. Also, make sure applicationId in android/app/build.gradle is the same as your package name in AndroidManifest.xml(You may forget to change applicationId after changing package name sometimes). This applicatioonId or package name in manifest file should be the name of your android package name in firebase app.

Sachin
  • 389
  • 5
  • 11
5

For platform exception 10, try this:

  1. Generate a new SHA1 fingerprint on your machine,
  2. Go to your firebase android app setting in Firebase Console
  3. Click on add new fingerprint in your android app settings
  4. Paste the new SHA1 fingerprint into the field
  5. Generate a new json config file
  6. Replace the config file in android directory
  7. Run flutter clean
  8. Run your project
Eefret
  • 4,724
  • 4
  • 30
  • 46
4

In my case, none of the answers solved the problem. After some thinking, I realized that sometime ago I have changed the package name of my application. If it is your case, you should simply create another application inside your Firebase project with your new package name and download google-services.json file again.

4

This happened to me also when I have reinstalled my OS. Just run ./gradlew signingReportand copy the SHA-1 and SHA-256 into Firebase config "add fingerprint"

Zozo
  • 185
  • 1
  • 2
  • 15
3

This might seem silly, but that just happened to me now (after having some experience working with firebase in the past). I noticed that I did not enable Google authentication. Make sure you do that, as you might still see the login prompt (showing you your phone's google users, without it being enabled).

Guy
  • 145
  • 3
  • 12
3

I tried all of the above answers and none worked. I'm putting my solution here in case someone runs into an edge case like mine:

  1. Mine didn't work with the above answers because I'm installing the app via Firebase App Tester (Firebase Distribution) and it resigned the app with entirely new test certificates, not the usual debug or release certificates you can get from Android Studio
  2. To solve it, go to Firebase App Distribution from Firebase Console and copy the test certificates SHA-1 and SHA-256 firebase app distribution certificates
  3. Enter these new certificates in Firebase Project Settings
Long Le
  • 301
  • 2
  • 2
3

This answer has already more 30 answer but this is more COMPLETE STEP BY STEP APPROACH to solve this bug.

  1. Most likely you do not have debug.keystore in your C/User/.android directory. To generate one, do the following

$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

use organization name Android country code US and name Android Debug

  1. when you have done so, navigate to your android flutter directory where gradlew is located and do the following

./gradlew signingReport

  1. You will have list of SHA1 SHA256 keys. copy both keys that is named debug.keystore to your flutter project firebase project settings (where you download google-services.json)

Flutter clean and rebuild your project.

ghifari.akbar
  • 119
  • 1
  • 7
2

You should generate SHA-1 and SHA-256 for each pc that you used. And add them all to firebase project settings.

And you should fill the form in OAuth Consent tab.

Gökhan E.
  • 75
  • 8
2

If it previously worked but now are using a different PC, you'll need to add new SHA-1/SHA-256 fingerprints generated by that PC to your project in Firebase. A good step-by-step example on doing that: https://stackoverflow.com/a/56091158/5365164

Sludge
  • 6,072
  • 5
  • 31
  • 43
  • 1
    By explaining the rootcause, it's much easier to find the correct answer, thank you! – C.K. Mar 01 '22 at 00:18
2

Got the same issue. I checked the signingReport and found that the release SHA1 and SHA256 were different from others. I added these values in firebase and re-downloaded the google-services.json. This solved the issue.

Also, run flutter clean before building apk.

2

If your implementation works everywhere but not on Android, make sure that you use the correct WEB clientId supplied to GoogleProvider(clientId: clientId) when using firebase_ui_auth package.

I repeat: Use WEB clientId to make Google SignIn work on Android.

This is completely counterintuitive and not documented anywhere. It took me three days of trial and error until I finally found this comment.

Lukas Nevosad
  • 196
  • 2
  • 9
  • For me it was to opposite. I used clientId to make it work on web, and it didn't work on Android until I removed it. https://github.com/flutter/flutter/issues/107532 – mirkancal Mar 08 '23 at 05:06
1

Make sure SHA-1 must be a debug key which is generated in your system only, and then download google-services.json file append that to your project

1

I had the issue and took 5 hours to get it solved. I remember I read somewhere that API Exception 10 means that there is an issue with the fingerprints. So, it had to be the keystore or a misconfiguration in firebase. Eventually, it was the keystore. I'm still not sure of why this worked but this is what I did, by the way, I'm using Windows 10:

1.) Make sure that on the file android/build.gradle I had the following:

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

2.) I added these two lines to the file android/gradle.properties

android.useAndroidX=true
android.enableJetifier=true

3.) Navigated to C:\Users\YOURUSER\.android and deleted the following:

debug.keystore
debug.keystore.lock

4.) Open the terminal as admin, and generated the debug keystore in this directory.

$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

Obtained the fingerprints:

$ keytool -list -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android 

5.) Added the SHA1 fingerprints to the configuration in firebase

That was it on my end. I hope it helps someone.

Morfinismo
  • 4,985
  • 4
  • 19
  • 36
1

Please make sure you do this:

ikhsanudinhakim
  • 1,554
  • 16
  • 23
1

However, the answers given above are correct, but still, if you are having issue then don't forget to verify the signingConfig {} section of the app/build.gradle. It should not have any unwanted keystore file reference, which may be causing a mismatch with google-services.json and the keystore.

RamKr
  • 756
  • 10
  • 17
1

In my case it was a silly mistake,make sure that your applicationId in firebase like : 'com.example.appname' matches exactly with the applicationId in your app/src/build.gradle file,under the defaultConfig{}.No spelling errors,no upper case,lower case letter conflicts.In my case one letter was upper case which caused all the problems.

1

Along with the steps suggested by others running ./gradlew clean worked for me.

Shubham Jain
  • 876
  • 1
  • 9
  • 17
1

Changing the date on your phone manually also results in a Platform Exception when trying to sign in with google. At least with the flutter google-sign-in library.

Max Tromp
  • 690
  • 7
  • 13
1

I know this issue has many replies already but I haven't seen this one yet. I solved ApiException: 10 by cleaning up!

  1. Removed unused OAuth 2.0 Client IDs from https://console.cloud.google.com/apis/credentials
  2. Removed unused fingerprints from the Firebase console.
  3. Download google-services.json again
activout.se
  • 6,058
  • 4
  • 27
  • 37
1

In my case, the problem was at the point that when I added flavors to my project, I set a different application-id for each flavor. But at the Firebase console, I had only one. Double-check the application ID, please.enter image description here

OnlyTarg
  • 190
  • 10
1

You need to add your SHA-1 and SHA-256 to your Firebase project. If you've published your app using Play App Signing, a requirement when using Android App Bundle, you can get your SHA-1 from the Google Play Console on the Release > Setup > App Integrity page.

1

This assumes you have already enabled OAuth in the Google Cloud Console for your Firebase Project.

  1. go into the the android folder i.e. myProjectName/android
  2. run ./gradlew signingReport (Mac/Linux) or gradlew.bat signingReport (Windows), to get the hashes of the debug and release key
  3. now go into the project settings of your firebase project and add the hashes under the fingerprint section of your apps
  4. run flutter clean to make sure not to use old data
  5. run flutterfire configure (this will add the necessary oauth_client entries in the google-services.json under android/app)
  6. run your app, now it should be working
tonik
  • 465
  • 1
  • 4
  • 15
0

In android/app/build.gradle I changed the dependencies from com.android.tools.build:gradle:3.1.3/com.google.gms:google-services:3.2.1 to com.android.tools.build:gradle:3.2.1/com.google.gms:google-services:4.2.0. And it worked.

Boyan Bozhidarov
  • 2,675
  • 2
  • 7
  • 6
0

While registering the app in Firebase I changed my applicationId to something that suits my app. However, this resulted in a second Flutter app being installed on my phone when I ran the debugger (Of course, due to the change in applicationId). So the thing that worked for my situation, was to remove both the installations and re-install the app.

NielsB95
  • 32
  • 3
0

I tried everything above and nothing worked. My mistake was I had multiple android studio version folders in my drive and I was feeding wrong SHA1 key in firebase settings.

shahana kareen
  • 364
  • 4
  • 10
0

Building an appbundle (which is recommended by Google Play and Flutter) will cause this error. Building an apk will resolve this.

See issue 58194425

Simpler
  • 1,317
  • 2
  • 16
  • 31
0

Please ensure the signing certs you are using on the firebase console is same as what is used in signingConfigs >> debug configuration in app/build.gradle file while still in development. Missmatch causes error.

Tonui Nicholus
  • 395
  • 2
  • 8
0

This fixed it for me. I did a small refactor in a new project. I thought I was using my old google-services.json file but I had been using the wrong file. I tried everything else for two days before realizing this simple error.

Oprimus
  • 1,652
  • 3
  • 11
  • 20
0

This was helped to me (was a problem importing the SHA1)

cd .android i used and copied the SHA1 key and pasted in firebase, project configuration, android application, SHA certificate

keytool -list -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android

and i created also one more key with:

keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkeytwo -keypass android -keyalg RSA -keysize 2048 -validity 10000

and used this to take one more SHA key:

keytool -list -v -keystore debug.keystore -alias androiddebugkeytwo -storepass android -keypass android

i copied and pasted adding one more key in my firebase project.

also downloaded the google-services.json and pasted in Android/app inside the flutter project.

This worked properly, my pubspec.yml depencies:

  http: ^0.12.0+2
  cupertino_icons: ^0.1.2
  firebase_auth: ^0.15.1
  firebase_analytics: ^5.0.6
  firebase_core: ^0.4.2+1
  google_sign_in: ^4.0.14

my code:

    Widget _signInButton() {
    return OutlineButton(
      splashColor: Colors.grey,
      onPressed: () async {
        await signInWithGoogle()
            .then((FirebaseUser user) => print(user.displayName))
            .catchError((e) => print(e));

      },

    );
  }

import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';

final FirebaseAuth _auth = FirebaseAuth.instance;
final GoogleSignIn googleSignIn = new GoogleSignIn();

Future<FirebaseUser> signInWithGoogle() async {
  final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
  final GoogleSignInAuthentication googleSignInAuthentication =
      await googleSignInAccount.authentication;

  final AuthCredential credential = GoogleAuthProvider.getCredential(
    accessToken: googleSignInAuthentication.accessToken,
    idToken: googleSignInAuthentication.idToken,
  );

  final AuthResult authResult = await _auth.signInWithCredential(credential);
  final FirebaseUser user = authResult.user;
  print(user.displayName.toString());
  assert(!user.isAnonymous);
  assert(await user.getIdToken() != null);

  final FirebaseUser currentUser = await _auth.currentUser();
  assert(user.uid == currentUser.uid);

  return user;
}

void signOutGoogle() async {
  await googleSignIn.signOut();

  print("User Sign Out");
}

I hope this work.

Pedro Molina
  • 1,101
  • 12
  • 12
0

I get this error: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 7: ,null) Maybe solution is good for you.

And I realise my debug device (android debug mode) not connected to internet. I think authentication is failed so method return null or user equal to null.

Returned variable must check before using.

0

i too had same issue.

  1. i had set Consent Screen.
  2. Added google_play_services.json
  3. had enabled Google SignIn
  4. added required plugin in flutter

but it was not working, i was getting same API Exception-10, gsm error

after adding SHA1 it started working

Raveesh G S
  • 524
  • 6
  • 7
0

Works great for me:

Change the minSdkVersion to 21 in all of your files (CTRL+SHIFT+R)

Jonathan
  • 1,955
  • 5
  • 30
  • 50
0

You can use real device, as this issue persists on the emmulator or simmulator sometimes.

Riyazat Durrani
  • 588
  • 1
  • 8
  • 20
0

Go to your java bin folder:

*C:\Program Files\Java\jdk-19\bin*

Now type in the below command in your cmd replacing your_user_name with your owns:

keytool -list -v -keystore "c:\users\your_user_name\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

Hope that helps!

Apurv Jha
  • 454
  • 3
  • 17
0

In my case, turns out that, after setting the SHA-1 and SHA256 keys in Google Firebase, the json files got changed. Also changing the project name in settings in firebase also changed the json files. I re-downloaded the new json files and it solved the problem.

Ian Anuta
  • 1
  • 1
0

If you did everything but still you can not log in use google then I think you use an emulator. Switch to real device and hope it will be work

Musfiq Shanta
  • 1,298
  • 13
  • 9
0

I faced a similar problem. but I solved it by taking a simple step.

First, let me tell you how the problem happened with my project:

I have linked my Flutter app to the Google Cloud Console to use Google Sign-In without Firebase. And it was working. Later, I linked the app (the Flutter app) to Firebase to use phone authentication. After this, when I tried to log in with Google Sign In, this error was thrown: "PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10:, null, null)".

The reason was, When I call this method:

final response = await _googleSignIn.signIn();

The request was sent to Firebase, not Google Cloud Console. So, I tried this solution, and the error was solved:

  1. The solution is to just open your "google_services.json" file and delete the "client_id" from the this code in google_services.json file.

 "oauth_client": [         {     "client_id": "872887541893-6rib4t0mk07gu1l80emetda6o65e2m76.apps.googleusercontent.com",           "client_type": 3         }       ], 2. Run this command on your app's VSC terminal.    2.1.flutter clean 2.2. flutter pub get then run your app. it worked for me. Let me know if you have an issue with the above explanation.

habeshacoder
  • 109
  • 1
  • 5
0

I had to set my android application id. for some reason flutter set my application id to com.example.dev. Changing the application Id fixed it.

user3413723
  • 11,147
  • 6
  • 55
  • 64