You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter Google Sign In AAB版本登录失败问题求助(PlatformException错误)

解决Google Sign In在Play商店AAB版本中出现的PlatformException(sign_in_failed, e5.b:10:)问题

问题概述

本地debug、release、profile版本中Google Sign In功能正常,但将AAB上传至Google Play商店后,用户登录时出现错误:PlatformException(sign_in_failed, e5.b: 10:, null, null)。已完成Firebase配置、Google控制台设置及SHA1密钥相关操作,且应用通过Google审核。

环境依赖

pubspec.yaml中谷歌相关依赖:

google_mobile_ads: ^3.0.0
google_sign_in: ^6.1.1
google_sign_in_dartio: ^0.2.2+1
googleapis: ^10.1.0
firebase_core: ^2.13.0
firebase_messaging: ^14.6.5

核心解决方案

1. 配置Play App Signing的签名指纹

当上传AAB到Play商店时,默认会启用Play App Signing,此时应用的实际签名密钥由Play提供,而非你本地的签名密钥:

  • 登录Google Play控制台,进入应用 → 应用签名,复制应用签名密钥下的SHA-1和SHA-256值
  • 打开Firebase控制台,进入项目 → 项目设置 → 应用,找到对应Android应用,点击添加指纹,粘贴上述SHA值
  • 打开Google Cloud Console,进入项目 → API和服务 → 凭据,找到你的Android类型OAuth客户端ID,编辑并添加上述SHA值

2. 验证OAuth客户端ID配置

  • 代码中serverClientId必须使用Web应用类型的OAuth客户端ID,而非Android客户端ID
  • 确认Web客户端ID的已授权重定向URI与后端验证的回调地址一致(若使用后端校验token)

3. 确保Google Sign-In API已启用

进入Google Cloud Console → API和服务 → 已启用的API和服务,检查Google Sign-In API是否处于启用状态,若未启用则手动开启。

4. 补充代码优化

  • 初始化GoogleSignIn时添加必要的scopes,确保能获取到邮箱等权限:
static final googleSignInInstance = GoogleSignIn(
  serverClientId: 'MY_CLIENT_ID',
  scopes: [
    'email',
    'profile',
  ],
);
  • 捕获异常时打印详细日志,便于后续排查:
catch (e) {
  print('Google Sign In Error Detail: $e');
  Get.snackbar(
    'Warning',
    'Google Sign in failed. Try again later.',
    colorText: AppColors.black,
    backgroundColor: AppColors.white,
    duration: const Duration(seconds: 5),
  );
}

5. 复查Play商店权限声明

确认应用在Play商店的应用内容页面中,已正确声明Google Sign In所需的权限(如获取用户邮箱、基本信息等),避免因权限声明缺失导致功能受限。

内容的提问来源于stack exchange,提问作者Dawntree

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 03:52:53