34

The line where is going to crash:

GoogleSignInAccount googleUser = await _googleSignIn.signIn();

What have I tried:

  1. I've generated my SH1 key with this command keytool -list -v \ -alias androiddebugkey -keystore ~/.android/debug.keystore
  2. Adding SH1 encryption into console.firebase.google.com
  3. Re-downloading the google-service.json
  4. Copying the debug.keystore from .android to MyProject/android
  5. Run in debug and release
  6. 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'
  7. 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.
  8. 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:

  1. Google sign in doesn't work after release of flutter app
  2. Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  3. 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.

4
  • When exactly do you encounter this error? Commented May 17, 2019 at 14:49
  • 1
    After 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. Commented May 17, 2019 at 14:58
  • I've added on the question the line where is going to crash. Commented May 17, 2019 at 15:07
  • Have 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 Commented May 17, 2019 at 15:58

22 Answers 22

57

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.

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

It's not work with me
Yes, for 12500 error code, this is working... Thanks.
Google sign-in is working with my physical devices perfectly, but with the emulator, it shows exception 12500. what I am missing?
nope not true. already have the email address.
the support email is configured in two different places, first: in the app upon configuration, second: on enabled google login (this second one was in my case the error 12500)
21

In my case, I have not enabled Google Sign In method.

enter image description here

Comments

13

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.

enter image description here

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.

3 Comments

I added a logo like you suggested and it miraculously worked. Bit ridiculous but at least it's sorted now!
Oh, Lord! This was a life saver. I was breaking my head with SHA 1 and google-services.json
Doesn't seem to fix it for me. Furthermore, once I add an Icon it seems that I need to verify this with google, wich can take up to 6 weeks. I have literally tried everything on Stackoverflow but nothing seems to work...
7

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.

1 Comment

Dude I searched evrything... and its just the Playstore....
3

I faced the same issue, I resolved it by adding the debug / release SHA1 and SHA256 certificate fingerprint using Keytool

Release

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

Debug

keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

More details here: https://developers.google.com/android/guides/client-auth

Comments

3

Change your emulator to another one that supports Google Play Store

1 Comment

Your 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.
2

After following all the steps mentioned in the documentation, even I was facing the same issue. One thing worked for me is adding the support email in the setting page of firebase console

Comments

2

Go to the API & Servcies page of your google account and make sure to select the project of your interest in the top left corner as shown below

enter image description here

Make sure you have the support email ID entered in the above

And all the below fields must have a value

enter image description here

Try logging in now, it will work!

Comments

1

I also tried almost all answer that I can search from internet.So I decide to tried ios side then it still give me error "403 restricted client".Then I determine it's server side issue .Finally I found that Forgot to set support e-mail address in Google Developers Console > API and service > certificate > user consent screen link and this option also in your Firebase project setting .After set up everything should work.Hope this will help you.

Comments

1

I ran exatly into the same issue, what solved the issue for me was to add a SHA-256 fingerprint additionally to the SHA-1

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

Hope that works for you too!

Comments

1

Just to add to this already huge list of ideas. After trying all of the things listed here I was still getting the error.

I had to add myself as a test user under the OAuth Consent Screen.

Comments

1

POSSIBLE CASE 2023

I had to face this problem too, during testing everything was working fine, but when I changed my project (actually build.gradle was the problem) to release mode the sign in process stopped to work as it was used to.

I tried to fill all the fields on Oauth consent screen (https://console.developers.google.com/apis/credentials), but nothing changed.

I also tried to check my SHA on Firebase, but both SHA-1 and SHA-256 were there.

As last resource I wanted to check my current SHA so in app/android folder I runned: ./gradlew signinReport and I found out that the SHA were changed.

So I uploaded them on Firebase and now everything is working fine.

In the end, check the SHA twice.

Comments

1

Check Application ID:-

Package Name on Google api console and Application Id in your app must be same, in my case it was different,

enter image description here

Comments

1

In my case, the Google Authentication provider was set with a support email and I was facing the same problem. So, I deleted the previous porvider and re-enabled a new Google Authentication provider and replaced old google-service.json file with newly downloaded file in <root>/android/app/ folder. This solved my problem.

Comments

0

had the same issue was using visual studio when I changed to android studio it worked. I guess because I am signed into firebase with android studio i wander if i can do the same with VS oh well hopefully this helps someone

Comments

0

In my case, I forgot to enable To add users manually, enable Email/Password as a sign-in method enter image description here

1 Comment

As 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.
0

In my case I had to set up two things:

  1. Go to Google Cloud console, select your app and in consent screen fill out the information required.

  2. I was using an emulator without Play Store. After I set up an emulator with Play Store installed, it worked.

Comments

0

In case it helps anyone: Try to run it on iOS, it might give you a better error description. In my case, I got the ApiException 12500 error on Android over and over again because I send an unknown scope:

  final _googleSignIn = GoogleSignIn(
    scopes: <String>[
      'name', // < "name" scope does not exist and causes ApiException 12500 on android
      'email',
    ],
  );

Running it on iOS gave me the exact error right away

Comments

0

Here is what works for me i have created sha1 from my production key store key.jks file enter this

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

to your terminal give your keystore name <your-key-name> here and path of your keystore file or jks path here <path-to-production-keystore>.

this will genrate different SHA1 from your debug SHA1 put that SHA1 into firebase settings where is SHA certificate fingerprints

Authenticating Your Client Google Reference

Comments

0

The other reason this issue may occur is if you have added scopes that are not approved in the OAuth screen.

Bear in mind that making certain changes to the OAuth screen will trigger Google's verification (this seems to include changes to the logo!)

Comments

0

Set up the following OAuth 2.0 Client IDs
* Web Application (Use this client id)
* Android Client with debug SHA1
* Android Client with keystore SHA1

In my case I had to also add another Android Client with the SHA1 of the app signing key from the Play store console

Of course update the google-service.json

final googleSignIn = GoogleSignIn(
    serverClientId: 'CLIENT-ID-FROM-WEB-APP',
    scopes: [
      'openid',
      'email',
      'profile',
    ],
  );

Comments

0

The issue I faced was that I’m using a Huawei phone, which doesn’t support Google services. So, I tested the functionality on an emulator or another device that has access to Google services

2 Comments

Your 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.
This doesn't really answer the question and is not related to it. Your issue stemmed from not using Google; the original question was not about that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.