【问题标题】:Firebase Authentication: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null)Firebase 身份验证:PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null)
【发布时间】:2021-12-12 06:41:19
【问题描述】:

我正在尝试在 Flutter 应用中使用 Firebase 设置 Google 身份验证。

我在 Android 上收到此错误:

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

它发生在以下行:

GoogleSignInAccount? user = await googleSignIn.signIn();

我试过了:

  • 为发布和调试添加 SHA-1 和 SHA-256 密钥。我正在手动为发布进行密钥签名,因此 Android Studio 版本控制没有问题,但我已检查以确保密钥准确无误。
  • 向 Firebase 添加支持电子邮件
  • 将“apply plugin: 'com.google.gms.google-services''”行添加到我的 app\build.gradle。
  • 检查我是否已使用 BOM 将正确的依赖项添加到我的 app\build.gradle。
  • 将“classpath 'com.google.gms:google-services:4.3.10'”依赖项添加到我的 android\build.gradle。
  • 检查 AndroidManifest.xml 和 build.gradle 是否与我的 Flutter 项目具有相同的类名。
  • 检查 google-services.json 文件是否正确。
  • 多次运行“flutter clean”。
  • 检查是否启用了 Google 身份验证。

它适用于 iOS,因此很可能不是代码问题。它既不适用于调试也不适用于发布。从 Firestore 读取工作正常,因此 google-services.json 应该不是问题。我有一个设置了 OAuth 同意的类似项目,但没有解决问题(谷歌身份验证从未开始工作),所以我没有在这里完成,因为它很耗时。

我检查了很多 StackOverflow 问题,但没有一个解决方案有效。有什么建议吗?

【问题讨论】:

    标签: firebase flutter dart firebase-authentication google-authentication


    【解决方案1】:

    我想通了。我已经更改了我在 Firebase 中使用的包名称。我在 google-services.json 中对其进行了更改。但是我必须使用我的新包名称为我需要工作的每个密钥创建自定义 OAuth 密钥。

    【讨论】:

      猜你喜欢
      • 2020-01-06
      • 2022-11-02
      • 2019-10-04
      • 2019-11-29
      • 2020-12-30
      • 2021-11-28
      • 2019-06-30
      • 2019-10-01
      • 2020-08-15
      相关资源
      最近更新 更多