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

Flutter集成Firebase手机OTP验证遇reCAPTCHA令牌获取失败问题

Flutter Firebase手机OTP验证错误排查方案

核心错误指向证书哈希无效和Play Integrity服务绑定失败,导致reCAPTCHA验证不通过,最终OTP请求被拒绝。以下是针对性解决步骤:

错误日志

ForceRecaptchaFlow from phoneAuthOptions = false, ForceRecaptchaFlow from firebaseSettings = false
W/System  ( 4367): Ignoring header X-Firebase-Locale because its value was null.
D/TrafficStats( 4367): tagSocket(73) with statsTag=0xffffffff, statsUid=-1
I/PlayCore( 4367): UID: [10162]  PID: [4367] IntegrityService : requestIntegrityToken(IntegrityTokenRequest{nonce=DZbwPB95mzwtBbgqcpPKnQqBoNSKj0zFgVVgh1fvBG0, cloudProjectNumber=551503664846})
I/PlayCore( 4367): UID: [10162]  PID: [4367] IntegrityService : Initiate binding to the service.
I/PlayCore( 4367): UID: [10162]  PID: [4367] IntegrityService : Failed to bind to the service.
E/zzb     ( 4367): Play Integrity Token fetch failed, falling back to Recaptcha-9: Integrity API error (-9): Binding to the service in the Play Store has failed. This can be due to having an old Play Store version installed on the device.
E/zzb     ( 4367): Ask the user to update Play Store.
E/zzb     ( 4367):  (https://developer.android.com/google/play/integrity/reference/com/google/android/play/core/integrity/model/IntegrityErrorCode.html#CANNOT_BIND_TO_SERVICE).
D/EGL_emulation( 4367): app_time_stats: avg=41.80ms min=3.95ms max=507.57ms count=23
W/System  ( 4367): Ignoring header X-Firebase-Locale because its value was null.
W/Parcel  ( 4367): Expecting binder but got null!
E/FirebaseAuth( 4367): [GetAuthDomainTask] Error getting project config. Failed with INVALID_CERT_HASH 400
E/zzb     ( 4367): Failed to get reCAPTCHA token with error [There was an error while trying to get your package certificate hash.]- calling backend without app verification
W/System  ( 4367): Ignoring header X-Firebase-Locale because its value was null.
E/FirebaseAuth( 4367): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17093 null
D/FirebaseAuth( 4367): Invoking original failure callbacks after phone verification failure for +917977501362, error - This request is missing a valid app identifier, meaning that Play Integrity checks, and reCAPTCHA checks were unsuccessful. Please try again, or check the logcat for more details.

解决步骤

  • 确认证书哈希准确性

    1. 分别获取debug和release环境的SHA-1、SHA-256哈希值:
      • Debug环境:keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore(默认密码android)
      • Release环境:keytool -list -v -keystore 你的发布密钥文件路径
    2. 将所有哈希值添加到Firebase控制台的项目设置中
    3. 重新下载google-services.json文件,替换项目android/app目录下的旧文件
  • 修复Play Integrity绑定问题

    1. 确保测试设备的Google Play Store已更新至最新版本,更新后重启设备
    2. 若使用模拟器,选择带有Google Play服务的系统镜像(如Google APIs或Google Play版)
    3. 确认设备已登录有效的Google账号
  • 重置项目构建配置

    1. 清理项目缓存并重新构建:
      flutter clean
      flutter pub get
      cd android && ./gradlew clean && cd ..
      flutter run
      
    2. 再次确认Firebase控制台中电话登录功能已启用
  • 检查基础配置

    1. 确保pubspec.yaml中firebase_auth依赖版本与当前Flutter版本兼容
    2. 检查android/app/src/main/AndroidManifest.xml是否添加了网络权限:
      <uses-permission android:name="android.permission.INTERNET"/>
      

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 14:10:12