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

132,444

Solution 1

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

Solution 2

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

Solution 3

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/

Solution 4

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>

Solution 5

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

Share:
132,444

Related videos on Youtube

Boyan Bozhidarov
Author by

Boyan Bozhidarov

Updated on July 08, 2022

Comments

  • Boyan Bozhidarov
    Boyan Bozhidarov 5 months

    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!

  • Srini
    Srini almost 4 years
    Thanks for this. This helped. Worthwhile noting that both the SHA1 and SHA256 keys had to be added for the auth to work
  • Michael Nelson
    Michael Nelson over 3 years
    FYI, I had the same error even after configuring my sha fingerprints. Turns out i also had to add a support email address per github.com/flutter/flutter/issues/25909#issuecomment-4973786‌​19 .
  • mkkhedawat
    mkkhedawat about 3 years
    clean is very important
  • Ahmed Albarody almost 3 years
    where do I enable thant?
  • Guy
    Guy almost 3 years
    @AhmedAlbarody In your firebase console - choose authentication and then you need to enable the services you want to use.
  • BHuelse
    BHuelse almost 3 years
    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.
  • greybeard
    greybeard over 2 years
    I find it difficult to follow your answer: can you get help using English (not my 1st language)?
  • PRO GRAMMER
    PRO GRAMMER over 2 years
    For me that is the only thing that worked, my keytool generated not working SHA-1 / SHA-256
  • Tincho825
    Tincho825 over 2 years
    If step 4 didn't work, call gradlew like this instead: ./gradlew signingReport
  • Mark Rawlingson
    Mark Rawlingson over 2 years
    Chiming in to say this is also the only thing that worked for me. Tried everything else and spent days trying to solve the issue before finding this.
  • reverie_ss
    reverie_ss about 2 years
    this is the easiest method! this should be accepted.
  • Steve Rogers
    Steve Rogers about 2 years
    The best answer. Perfect.
  • ishallwin
    ishallwin over 1 year
    Thanks for the comment. I was finally able to resolve it. :)
  • user2897738
    user2897738 over 1 year
    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.
  • adrianvintu
    adrianvintu about 1 year
    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!
  • efesahin
    efesahin about 1 year
    solved my problem also
  • rahulserver
    rahulserver about 1 year
    you saved my day man!
  • ege men
    ege men 11 months
    This is the right solution. Additionally, if Firebase package-name and project package-name (path) do not match, you still get this error code:10.
  • Moacir Schmidt
    Moacir Schmidt 11 months
    Removed unused fingerprints and update google-services.json solved for me
  • Saugat Thapa 11 months
    all the above didnt work but this did... thank u so much!
  • Miki
    Miki 10 months
    This was helpful man thanks for sharing!
  • Saiful Islam
    Saiful Islam 9 months
    You just saved my day.
  • C.K.
    C.K. 9 months
    By explaining the rootcause, it's much easier to find the correct answer, thank you!

Related