'When I log in using google_sign_in in Flutter App, PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null)
I am developing a Flutter App using google_sign_in. https://pub.dev/packages/google_sign_in
When I log in using google_sign_in in Flutter App, an error occurs:
PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null)
This only happens on the Android Emulator.
Building with Flutter v1.26 works fine, but only when building with Flutter v2.10.
Flutter App signing was done normally, and the hash value was properly registered in Firebase.
This is the cert value of app-release.apk.
Signer #1:
Signature:
Owner: CN=Raymond Jeon, OU=Dev, O=Dev, L=Seoul, ST=Seoul, C=KR
Issuer: CN=Raymond Jeon, OU=Dev, O=Dev, L=Seoul, ST=Seoul, C=KR
Serial number: 2a08edea
Valid from: Thu Aug 12 11:53:45 KST 2021 until: Mon Dec 28 11:53:45 KST 2048
Certificate fingerprints:
MD5: D9:B4:24:A9:XX:XX:XX:03:8B:44:41:DC:C6:78:E2:87
SHA1: D9:94:3F:B7:XX:XX:XX:XX:68:22:A8:5D:23:78:07:8A:67:16:EE:C3
SHA256: 0B:47:15:B3:XX:XX:XX:XX:37:A3:51:CF:53:2A:42:42:EB:D5:91:25:BE:3F:7B:0E:49:58:73:36:1A:DF:AA:3A
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 3
Extensions:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: B0 XX XX XX 0B 79 27 3D B9 00 D0 C1 92 20 F6 3F .....y'=..... .?
0010: 60 B0 A0 2B `..+
]
]
The information below is the same as the SHA1 value registered in firebase.
SHA1: D9:94:3F:B7:XX:XX:XX:XX:68:22:A8:5D:23:78:07:8A:67:16:EE:C3
Why is this only happening in Flutter v2.10?
I downloaded the google-services.json file again and installed it.
I modified android/app/build.gradle file.
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.android.gms:play-services-basement:18.0.0'
implementation 'com.google.firebase:firebase-analytics:20.1.0'
implementation 'com.google.firebase:firebase-crashlytics:18.2.8'
implementation 'com.google.firebase:firebase-messaging:23.0.0'
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:29.1.0')
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
I modified android/build.gradle too.
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10' // Google Services plugin
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1' // firebase crashlytics
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://naver.jfrog.io/artifactory/maven/'
}
}
}
flutter doctor -v
[✓] Flutter (Channel stable, 2.10.2, on macOS 12.0.1 21A559 darwin-arm, locale en-KR)
• Flutter version 2.10.2 at /Users/gracegyu/fvm/versions/stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 097d3313d8 (6 days ago), 2022-02-18 19:33:08 -0600
• Engine revision a83ed0e5e3
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at /Users/gracegyu/Library/Android/sdk
• Platform android-31, build-tools 32.0.0
• ANDROID_HOME = /Users/gracegyu/Library/Android/sdk
• Java binary at: /Users/gracegyu/.Trash/Android Studio(Intel).app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
[✓] Android Studio (version 2021.1)
• Android Studio at /Users/gracegyu/.Trash/Android Studio(Intel).app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[✓] VS Code (version 1.64.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.34.0
[✓] Connected device (3 available)
• Raymond’s iPhone13 (mobile) • 00008110-001C3DD93A29801E • ios • iOS 15.4 19E5235a
• macOS (desktop) • macos • darwin-arm64 • macOS 12.0.1 21A559 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.109
[✓] HTTP Host Availability
• All required HTTP hosts are available
The same error occurs even when I test google_sign_in with an older version of 5.0.0.
Solution 1:[1]
try this
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
then go this file android>gradle>wrapper>gradle-wrapper.properties and change zip file version
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
Solution 2:[2]
Please update your build.gradle file
classpath 'com.google.gms:google-services:4.3.10'
try this ->
1.Select your firebase project
2.Select Android
3.Open terminal inside your flutter project
4.cd android
5. ./gradlew signingReport or gradlew signingReport
6.Paste your package name and your SHA1 key
7.Download Client Information
8.Download and replace the google-services.json
9.flutter clean
Solution 3:[3]
It was solved by removing the clientId parameter from the GoogleSignIn function as shown below.
_googleSignIn = GoogleSignIn(
// clientId: '233xxxxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com',
scopes: <String>[
'email',
],
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Zekai Demir |
| Solution 2 | |
| Solution 3 | Raymond |
