PlatformException (PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null))
Solution 1
The OP, @Mircea, specifically mentioned error 12500. This is how I overcame that error:
I have spent the last few days running into the same problem. I refactored my code dozens of times, added break points, reset the SHA-1, SHA-256 and did just about every other 'code' based solution I could find. I was constantly running into the error:
E/flutter (11935): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null)
I was losing my mind so I decided to start with fresh eyes and move slowly through solutions one more time. I noticed an obscure post nestled deep in a thread that mentioned something about having a support email. It was not until I added a said support email that things "magically" started working. I've attached a screenshot below of the Firebase settings for my project.
Solution 2
In my case, I have not enabled Google Sign In method.
Solution 3
You need to complete "Oauth consent screen"
I went to this page (https://console.developers.google.com/apis/credentials) Do not forget to select your project on the list (top left). Then go on "Oauth consent screen"
I filled the application logo and the application homepage link and aplication privacy policy link (with the project.firebaseapp.com) and saved.
Now it's working, I can login.
This must be explained in the documentation. People are going to be crazy and to don't try flutter with this kind of lack of documentation.
Solution 4
In my case, the problem was due to incompatible emulator. The emulator didn't had playstore.
I created a new AVD which has playstore in it. And then it worked!
Reference to create new emulator with Playstore
Also, verify that you have added the SHA1 key on firebase console.
Solution 5
change your émilator to anothoer one how support google play store
Mircea
Updated on July 05, 2022Comments
-
Mircea almost 2 years
The line where is going to crash:
GoogleSignInAccount googleUser = await _googleSignIn.signIn();
What have I tried:
- I've generated my SH1 key with this command
keytool -list -v \ -alias androiddebugkey -keystore ~/.android/debug.keystore
- Adding SH1 encryption into console.firebase.google.com
- Re-downloading the google-service.json
- Copying the
debug.keystore
from.android
toMyProject/android
- Run in debug and release
-
Adding into
android/build.gradle
those lines:- classpath 'com.android.tools.build:gradle:3.2.1'
- classpath 'com.google.gms:google-services:4.2.0'
-
Adding into
android/app/build.gradle
this lines:- implementation 'com.google.firebase:firebase-core:16.0.9' under dependencies
- apply plugin: 'com.google.gms.google-services' on the end of the file.
- Creating a file named
release-signing.properties
under my project folder with those lines in it.- storeFile=debug.keystore
- keyAlias=androiddebugkey
- storePassword=android
- keyPassword=android
Also, I've searched in ALL StackOverflow question that I could found for this question, and none of them was useful for me.
My pubspec.yaml:
firebase_core: ^0.4.0+1 firebase_analytics: ^3.0.1 cloud_firestore: ^0.11.0+2 firebase_auth: ^0.11.1 google_sign_in: ^4.0.1+3 rxdart: ^0.22.0
Auth class:
class AuthService { final GoogleSignIn _googleSignIn = GoogleSignIn(); final FirebaseAuth _auth = FirebaseAuth.instance; final Firestore _db = Firestore.instance; Observable<FirebaseUser> user; Observable<Map<String, dynamic>> profile; PublishSubject loading = PublishSubject(); AuthService() { user = Observable(_auth.onAuthStateChanged); profile = user.switchMap((FirebaseUser user) { if (user != null) { return _db .collection('user') .document(user.uid) .snapshots() .map((snap) => snap.data); } else { return Observable.just({}); } }); } Future<FirebaseUser> googleSignIn() async { loading.add(true); GoogleSignInAccount googleUser = await _googleSignIn.signIn(); GoogleSignInAuthentication googleAuth = await googleUser.authentication; // FirebaseUser user = await _auth.signInWithGoogle( // accessToken: googleAuth.accessToken, idToken: googleAuth.idToken); final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken, ); FirebaseUser user = await _auth.signInWithCredential(credential); updateUserData(user); print("Sign in" + user.displayName); loading.add(false); return user; } }
Main class:
void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. AuthService authService = AuthService(); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blueGrey, ), home: Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ MaterialButton( child: Text("Log in with Google"), color: Colors.blueGrey, textColor: Colors.deepOrange, onPressed: () => authService.googleSignIn(), ), MaterialButton( child: Text("LogOut"), color: Colors.redAccent, textColor: Colors.purple, onPressed: () => authService.signOut(), ), ], ), ), ), ); } }
Now if any of you could point me in the right direction I would be very grateful.
Here are some stackoverflow links that I've tried already:
- Google sign in doesn't work after release of flutter app
- Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
- Google Sign In error 12500
I didn't have luck with any of them, please let me know what do you think and how can I fix it.
-
ThinkDigital almost 5 yearsWhen exactly do you encounter this error?
-
Mircea almost 5 yearsAfter I'm pressing the "Log in with Google" button I will open a pop-up where I need to select my google account. I will receive this error right after I will press on my google account.
-
Mircea almost 5 yearsI've added on the question the line where is going to crash.
-
ThinkDigital almost 5 yearsHave you checked the logcat for a more detailed error message? Since it's a platform exception, it's failing in the platform side, so you'll sometimes find error messages in the android or iOS logs that you won't find in flutter
- I've generated my SH1 key with this command
-
Tom O'Sullivan almost 5 yearsI added a logo like you suggested and it miraculously worked. Bit ridiculous but at least it's sorted now!
-
Harikrishnan over 3 yearsOh, Lord! This was a life saver. I was breaking my head with SHA 1 and google-services.json
-
Admin over 2 yearsYour answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
-
Muhammad Hasan Alasady over 2 yearsIt's not work with me
-
ege men over 2 yearsYes, for 12500 error code, this is working... Thanks.
-
Admin about 2 yearsAs it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.