Flutter Android FirebaseAuth Recaptcha发布模式验证失败求助
Flutter Android发布模式verifyPhoneNumber验证失败解决建议
关键排查与修复步骤
- 确认发布版签名匹配:发布打包必须使用Firebase后台登记的正式签名密钥,检查
android/app/build.gradle的signingConfigs配置,确保release块指向正确的密钥库文件、别名及密码,不能用debug密钥打包发布版。 - 启用Google Play Integrity API:原Android Device Verification服务已整合进Play Integrity API,前往绑定Firebase的GCP项目控制台,搜索并启用该API,确保项目关联无误。
- 更新并生效google-services.json:将包含发布版签名哈希的最新google-services.json替换到
android/app目录,执行flutter clean后重新打包,避免缓存旧配置。 - 适配Recaptcha静默验证:发布模式下Recaptcha为静默验证(不会弹出浏览器),需确保测试设备通过Play认证、安装了适配版本的Google Play服务;同时升级firebase_auth依赖到最新稳定版,避免版本兼容问题。
- 查看详细错误日志:通过
adb logcat -s FirebaseAuth过滤Firebase相关日志,定位具体失败原因(如Play Integrity验证不通过、Recaptcha配置问题等)。 - 调整androidx.browser依赖:移除旧版本依赖,添加兼容的最新版,在
android/app/build.gradle的dependencies块中写入:implementation 'androidx.browser:browser:1.6.0'
额外注意事项
- 若通过Google Play发布应用,需将Google Play提供的App Signing签名哈希(开启App Signing by Google Play时)也添加到Firebase后台。
- 优先使用真实设备测试发布版,模拟器可能无法通过Play Integrity验证。
内容的提问来源于stack exchange,提问作者Victor Moreira
相关产品推荐
相关产品推荐

