【问题标题】:PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) when using Flutter to build an appbundle使用 Flutter 构建 appbundle 时的 PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
【发布时间】:2020-01-31 07:32:55
【问题描述】:

我正在使用 firebase_authgoogle_sign_in 构建一个 Flutter 应用程序。

在一段时间内一切都运行良好,我在已发布产品上的所有现有用户都没有遇到任何问题,但不久前我开始收到新用户无法登录的报告。我没想太多直到报告开始积累。我发现他们收到了标题中发布的错误。我花了很多时间调查...

我已经浏览了此问题的所有其他 StackOverflow 条目:

  1. Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  2. PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  3. Exception has occurred. PlatformException (PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null))
  4. Flutter: Firebase: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  5. Flutter: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  6. Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
  7. com.google.android.gms.common.api.ApiException: 10:
  8. com.google.android.gms.common.api.ApiException: 10
  9. How to correct " com.google.android.gms.common.api.ApiException: 10: "
  10. Firebase Google Signin error: com.google.android.gms.common.api.ApiException: 10
  11. Google sign in failed com.google.android.gms.common.api.ApiException: 10:
  12. Why do I get com.google.android.gms.common.api.ApiException: 10:?
  13. Error with Google_sign_in plugin in flutter

我已经尝试了所有的解决方案:

  • Generated debug key
  • Firebase site 上输入了 SHA1 调试密钥
  • 已验证我的电子邮件已输入到 Firebase 网站。
  • 下载了google-services.json文件,放到android/app/目录下
  • 使用flutter build appbundle --debug构建flutter应用
  • PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

所以我也试过了:

  • 仅使用 Firebase 站点上的发布密钥并使用 flutter build appbundle --release 构建
  • 同时使用发布密钥和调试密钥
  • 上述每个组合使用 SHA256
  • 对于这些组合,我确定flutter clean 并将 google-services.json 文件替换为更新后的文件

  • 已验证 android/build.gradleandroid/app/build.gradleconfigured properly

  • 已验证“Google”已启用,因为在 Firebase 网站上启用了“登录方法”
  • 我什至用我的应用名称、徽标、电子邮件、主页、隐私和服务条款链接填写了 OAuth consent screen 并保存了

以下是我正在运行的版本:

  google_sign_in: ^4.0.7
  firebase_auth: ^0.14.0+5

android/app/build.gradle 的相关部分:

dependencies {
    implementation "androidx.appcompat:appcompat:1.1.0-alpha01"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation "com.google.android.gms:play-services-auth:16.0.1"
    implementation "com.google.android.gms:play-services-identity:16.0.0"
    implementation "com.android.support:support-v4:28.0"
}

apply plugin: 'com.google.gms.google-services' 

android/build.gradle 的相关部分:

buildscript {
   ext.kotlin_version = '1.2.71'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

颤振医生输出:

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.2, on Linux, locale en_US.UTF-8)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0-rc1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.38.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

所有测试均使用 Firebase 上的 Robo 测试实验室在多台设备上完成(仅查看登录是否成功,而不是测试 UI)。


TLDR; 最后,我终于发现如果我使用flutter build apk(而不是appbundle)构建apk,它就可以工作。然后我意识到问题开始的时间与 Flutter 开始建议我生成 appbundles 而不是 apks 的时间差不多。

是否有人能够在生成 appbundle 时使用 google_sign_in 使用 Flutter 登录 BRAND NEW USER?(请记住,之前登录过早期版本应用程序的现有用户无需问题。)

【问题讨论】:

  • 嗨,我在 Mac 上遇到了完全相同的问题,但该应用程序可以在 Windows 上运行。你使用的是什么操作系统?和java版本?我看到我们有相同的应用程序配置......如果我修复它,我会告诉你的!如果你修复它,请告诉我
  • @MauroSebastianVolpeParedes 我尝试在 Linux Mint 和 Windows 10 上构建。两者具有相同的行为(apk 有效,abb 错误)。 Windows 上的 jdk1.8.0_152。
  • 您是从一开始就注册了 Play Signing,还是您有后来注册的现有应用?
  • @Pierre,已经有一段时间了,但我认为这是我在一段时间后注册 Play 签名的 Play 商店中现有的应用程序。这有什么关系?
  • 试图看看这是否与签名认证有关,但可能不是。无法登录的设备之间有什么共同的模式吗?

标签: flutter firebase-authentication google-signin android-app-bundle googlesigninapi


【解决方案1】:

如果您使用 Internal App Sharing 在实际的 Android 设备(如我)上测试 Flutter 构建,则需要添加另一个应用签名证书指纹

在 Google Play Console 的左侧导航中转到:开发者工具 -> 内部应用共享

选择应用证书标签。应该看起来像这样:

Google Play - Internal App Sharing - Certificate

复制 SHA1 密钥并将其添加到 Firebase 控制台 -> 项目设置 -> [您的 Android 应用] -> SHA 证书指纹(使用按钮添加指纹)

下载您的更新的 google-services.json 并将其更新/添加到项目的 android/app 文件夹中。

这适用于新用户和现有用户。我使用flutter build appbundle构建了一个appbundle(不是APK)

这在 Google 的任何地方都没有记录,我在 Flutter 社区的其他地方也没有看到这个解决方案。在尝试了您引用的所有链接和其他几个链接之后,我在 Google Play 控制台中四处寻找时遇到了这个解决方案。

【讨论】:

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