Flutter Firebase谷歌登录Release模式失效(12500错误)求助
解决Release模式下谷歌登录返回12500错误的方案
以下是针对该问题的排查和解决步骤:
确认Release包实际使用的SHA1指纹
本地配置的签名信息可能和实际打包的不一致,直接从生成的Release APK中提取SHA1:keytool -printcert -jarfile your-release-app.apk将得到的SHA1指纹添加到Firebase控制台的项目设置中。
验证google-services.json的同步状态
- 确保
google-services.json文件放在app模块的根目录下 - 检查app/build.gradle末尾是否添加了谷歌服务插件:
apply plugin: 'com.google.gms.google-services' - 清理构建缓存后重新构建:
./gradlew clean assembleRelease
- 确保
核对Google Cloud Console的OAuth客户端配置
Firebase的SHA1配置会同步到Google Cloud,但偶尔会出现延迟或同步失败:- 进入Google Cloud Console的对应项目,打开「API和服务」->「凭据」
- 找到Android类型的OAuth 2.0客户端ID,确认其包含所有所需的SHA1指纹(本地Debug、本地Release、Google Play应用签名密钥),且包名与项目一致。
确认Google Play应用签名密钥的SHA1正确性
如果使用Google Play App Signing,必须使用Google Play控制台提供的签名指纹:
进入Google Play控制台->你的应用->「发布」->「应用签名」,复制页面中的SHA1指纹,核对Firebase中是否已添加该值。检查签名配置与混淆规则
- 确保app/build.gradle的release签名配置指向正确的密钥库:
signingConfigs { release { storeFile file("your-keystore.jks") storePassword "your-store-password" keyAlias "your-key-alias" keyPassword "your-key-password" } } buildTypes { release { signingConfig signingConfigs.release // 其他构建配置 } } - 若启用了R8/ProGuard,添加谷歌登录的防混淆规则到
proguard-rules.pro:-keep class com.google.android.gms.auth.** { *; } -keep class com.google.android.gms.common.** { *; } -keep class com.google.android.gms.tasks.** { *; }
- 确保app/build.gradle的release签名配置指向正确的密钥库:
内容的提问来源于stack exchange,提问作者rays7c
相关产品推荐
相关产品推荐

