简体   繁体   English

PlatformException (PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null))

[英]PlatformException (PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null))

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我已经使用此命令生成了我的 SH1 密钥keytool -list -v \ -alias androiddebugkey -keystore ~/.android/debug.keystore
  2. Adding SH1 encryption into console.firebase.google.com添加 SH1 加密到 console.firebase.google.com
  3. Re-downloading the google-service.json重新下载google-service.json
  4. Copying the debug.keystore from .android to MyProject/androiddebug.keystore.android复制到MyProject/android
  5. Run in debug and release在调试和发布中运行
  6. Adding into android/build.gradle those lines:添加到android/build.gradle这些行:

    • classpath 'com.android.tools.build.gradle:3.2.1'类路径'com.android.tools.build.gradle:3.2.1'
    • classpath 'com.google.gms:google-services:4.2.0'类路径 'com.google.gms:google-services:4.2.0'
  7. Adding into android/app/build.gradle this lines:添加到android/app/build.gradle这一行:

    • implementation 'com.google.firebase:firebase-core:16.0.9' under dependencies依赖项下实现 'com.google.firebase:firebase-core:16.0.9'
    • apply plugin: 'com.google.gms.google-services' on the end of the file.在文件末尾应用插件:'com.google.gms.google-services'
  8. Creating a file named release-signing.properties under my project folder with those lines in it.在我的项目文件夹下创建一个名为release-signing.properties的文件,其中包含这些行。
    • storeFile=debug.keystore storeFile=调试.keystore
    • keyAlias=androiddebugkey keyAlias=androiddebugkey
    • storePassword=android商店密码=安卓
    • keyPassword=android keyPassword=安卓

Also, I've searched in ALL StackOverflow question that I could found for this question, and none of them was useful for me.此外,我已经搜索了所有 StackOverflow问题,我可以找到这个问题,但没有一个对我有用。

My pubspec.yaml:我的 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:

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:总机 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:以下是我已经尝试过的一些 stackoverflow 链接:

  1. Google sign in doesn't work after release of flutter app 发布 flutter 应用程序后,Google 登录不起作用
  2. Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) Flutter 和 google_sign_in 插件:PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException:10:,空)
  3. Google Sign In error 12500 谷歌登录错误 12500

I didn't have luck with any of them, please let me know what do you think and how can I fix it.我对他们中的任何一个都不走运,请告诉我您的想法以及我该如何解决。

The OP, @Mircea, specifically mentioned error 12500. This is how I overcame that error: OP @Mircea 特别提到了错误 12500。这就是我克服该错误的方法:

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.我重构了我的代码数十次,添加了断点,重置了 SHA-1、SHA-256,并做了我能找到的几乎所有其他基于“代码”的解决方案。 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.我在下面附上了我项目的 Firebase 设置的屏幕截图。

在此处输入图片说明

You need to complete " Oauth consent screen "您需要完成“ Oauth 同意屏幕

I went to this page ( https://console.developers.google.com/apis/credentials ) Do not forget to select your project on the list (top left).我去了这个页面 ( https://console.developers.google.com/apis/credentials ) 不要忘记在列表中选择你的项目(左上角)。 Then go on "Oauth consent screen"然后进入“Oauth 同意屏幕”

I filled the application logo and the application homepage link and aplication privacy policy link (with the project.firebaseapp.com) and saved.我填写了应用程序徽标和应用程序主页链接和应用程序隐私政策链接(与 project.firebaseapp.com)并保存。

在此处输入图片说明

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.人们会发疯的,不要因为缺乏这种文档而尝试慌张。

In my case, I have not enabled Google Sign In method.就我而言,我尚未启用 Google 登录方法。

在此处输入图片说明

将您的 émilator 更改为另一个如何支持 google play 商店

我还尝试了几乎所有可以从 Internet 搜索的答案。所以我决定尝试 ios 端然后它仍然给我错误“403 受限客户端”。然后我确定它是服务器端问题。最后我发现忘记设置支持电子- Google Developers Console > API 和服务 > 证书 > 用户同意屏幕 链接中的邮件地址,此选项也在您的 Firebase 项目设置中。设置后一切正常。希望这对您有所帮助。

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对我有用的一件事是在 firebase 控制台的设置页面中添加支持电子邮件

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进入你google账户的API & Servcies页面,确保在左上角选择你感兴趣的项目,如下图

在此处输入图片说明

Make sure you have the support email ID entered in the above确保您在上面输入了支持电子邮件 ID

And all the below fields must have a value并且以下所有字段都必须有一个值

在此处输入图片说明

Try logging in now, it will work!现在尝试登录,它会起作用!

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我遇到了同样的问题,为我解决的问题是在 SHA-1 中添加了一个 SHA-256 指纹

as mentioned here -> Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)如此处所述-> Flutter 和 google_sign_in 插件: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

Hope that works for you too!希望这对你也有用!

had the same issue was using visual studio when I changed to android studio it worked.当我更改为 android studio 时,在使用 Visual Studio 时遇到了同样的问题。 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我想是因为我在 android studio 上登录了 firebase,如果我可以用 VS 做同样的事情,我会徘徊哦,希望这对某人有所帮助

I faced the same issue, I resolved it by adding the debug / release SHA1 and SHA256 certificate fingerprint using Keytool我遇到了同样的问题,我通过使用 Keytool 添加调试/发布 SHA1 和 SHA256 证书指纹来解决它

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此处有更多详细信息: https : //developers.google.com/android/guides/client-auth

Just to add to this already huge list of ideas.只是为了添加到这个已经很大的想法列表中。 I had to add myself as a test user under the OAuth Consent Screen.我必须在 OAuth 同意屏幕下将自己添加为测试用户。

In my case, the problem was due to incompatible emulator.就我而言,问题是由于模拟器不兼容。 The emulator didn't had playstore.模拟器没有Playstore。

I created a new AVD which has playstore in it.我创建了一个包含 playstore 的新 AVD。 And then it worked!然后它起作用了!

Reference to create new emulator with Playstore使用 Playstore 创建新模拟器的参考

Also, verify that you have added the SHA1 key on firebase console.此外,验证您是否已在 firebase 控制台上添加了 SHA1 密钥。

In my case, I forgot to enable To add users manually, enable Email/Password as a sign-in method enter image description here在我的情况下,我忘记启用要手动添加用户,启用电子邮件/密码作为登录方法在此处输入图像描述

Go to Play store and Search for "App Integrity" Go 播放商店并搜索“应用程序完整性”

Google play store app integrity Google Play 商店应用完整性

在此处输入图像描述

Then Copy the SHA Keys and Add into the Firebase or Google Cloud signing keys.然后复制 SHA 密钥并添加到 Firebase 或 Google Cloud 签名密钥中。

and then you are good to go.然后你对 go 就好了。

worked for me.为我工作。

POSSIBLE CASE 2023可能的案例 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.我也不得不面对这个问题,在测试期间一切正常,但是当我将我的项目(实际上是 build.gradle 是问题所在)更改为发布模式时,登录过程停止了,因为它已经习惯了。

I tried to fill all the fields on Oauth consent screen ( https://console.developers.google.com/apis/credentials ), but nothing changed.我试图填写Oauth 同意屏幕( https://console.developers.google.com/apis/credentials ) 上的所有字段,但没有任何改变。

I also tried to check my SHA on Firebase, but both SHA-1 and SHA-256 were there.我还尝试在 Firebase 上检查我的 SHA,但 SHA-1 和 SHA-256 都在那里。

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.作为最后一个资源,我想检查我当前的 SHA,所以在我运行的 app/android 文件夹中: ./gradlew signinReport并且我发现 SHA 已更改。

So I uploaded them on Firebase and now everything is working fine.所以我将它们上传到 Firebase,现在一切正常。

In the end, check the SHA twice.最后检查两次SHA。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) - Flutter: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) 未处理的异常:PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) - Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) Flutter 和 google_sign_in 插件:PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException:10:,空) - Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) Firebase 身份验证:PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) - Firebase Authentication: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) Flutter中的PlatformException(sign_in_failed,Status {statusCode = CANCELED,resolution = null},null)错误 - PlatformException(sign_in_failed, Status{statusCode=CANCELED, resolution=null}, null) error in Flutter Firebase Google Auth无法正常工作。 ApiException:12500 :,空 - Firebase Google Auth not working . ApiException: 12500: , null 如何捕获 Flutter Google 登录 PlatformException? - How do I catch Flutter Google sign-in PlatformException? Flutter:PlatformException(错误,无法找到包含<path> , 无效的)</path> - Flutter: PlatformException(error, Failed to find configured root that contains <path>, null) Flutter:PlatformException(PlatformException(,找不到文件,null,null))在 FlutterAudioRecorder2 上 - Flutter: PlatformException (PlatformException(, cannot find the file, null, null)) on FlutterAudioRecorder2 PlatformException (PlatformException(already_active, 图像选择器已经激活, null, null)) - PlatformException (PlatformException(already_active, Image picker is already active, null, null))
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM