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

Flutter Firebase手机号认证短信发送失败:Play Integrity及App Check问题求助

Flutter Firebase手机号认证发送验证码失败问题排查与解决

问题概述

配置Flutter应用的Firebase手机号认证时,发送短信验证码失败。已在Firebase控制台启用Play Integrity并配置应用指纹,调用FirebaseAppCheck.instance.activate方法后问题仍未解决。

关键错误日志

I/PlayCore( 5388): UID: [10182]  PID: [5388] IntegrityService : Initiate binding to the service.
I/PlayCore( 5388): UID: [10182]  PID: [5388] IntegrityService : Failed to bind to the service.
E/zzf     ( 5388): 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/zzf     ( 5388): Ask the user to update Play Store.
E/zzf     ( 5388):  (https://developer.android.com/google/play/integrity/reference/com/google/android/play/core/integrity/model/IntegrityErrorCode.html#CANNOT_BIND_TO_SERVICE).
E/OpenGLRenderer( 5388): Unable to match the desired swap behavior.
W/LocalRequestInterceptor( 5388): Error getting App Check token; using placeholder token instead. Error: com.google.firebase.FirebaseException: Too many attempts.
D/TrafficStats( 5388): tagSocket(167) with statsTag=0xffffffff, statsUid=-1
W/RecaptchaActivity( 5388): Error getting App Check token; using placeholder token instead. 
E/zzf     ( 5388): Failed to get reCAPTCHA token with error [There was an internal error in the web widget. [ {"code":"auth/internal-error","message":"{\"error\":{\"code\":403,\"message\":\"Requests from this Android client application <empty> are blocked.\",\"errors\":[{\"message\":\"Requests from this Android client application <empty> are blocked.\",\"domain\":\"global\",\"reason\":\"forbidden\"}],\"status\":\"PERMISSION_DENIED\",\"details\":[{\"@type\":\"type.googleapis.com/google.rpc.ErrorInfo\",\"reason\":\"API_KEY_ANDROID_APP_BLOCKED\",\"domain\":\"googleapis.com\",\"metadata\":{\"service\":\"identitytoolkit.googleapis.com\",\"consumer\":\"projects/891062597489\"}}]}}"} ]]- calling backend without app verification

日志核心问题点:

  • Play Integrity服务绑定失败(错误码-9):设备Play Store版本过旧
  • App Check获取token失败,提示尝试次数过多
  • 403权限拒绝:Android客户端请求被阻止,原因是API_KEY_ANDROID_APP_BLOCKED,关联身份工具包服务

当前初始化代码

void main () async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  await FirebaseAppCheck.instance.activate(
    androidProvider: AndroidProvider.debug,
    appleProvider: AppleProvider.appAttest,
  );
  runApp(
    MultiProvider(
        providers: [
          ChangeNotifierProvider(
            create: (context) => LocationProvider(), // 地图相关提供者
            child: const MyApp(),
          ),
        ],
      child: const MyApp(),
    )
  );
}

解决步骤

  • 更新Google Play Store:将测试设备上的Play Store更新到最新版本,重启设备后重新测试
  • 修正App Check配置:
    • 若处于开发调试阶段,确认Firebase控制台已添加应用的debug SHA-1指纹到App Check的允许列表中
    • 正式环境需将androidProvider切换为AndroidProvider.playIntegrity,并确保release指纹已正确配置
  • 修复API密钥限制:
    • 进入Google Cloud控制台,找到Firebase关联的API密钥
    • 检查API密钥的Android应用限制,确认已添加当前应用的包名和对应SHA-1指纹
    • 确保Identity Toolkit API已在Google Cloud控制台中启用
  • 重置请求次数:卸载应用清除本地缓存,或更换测试设备以解决“Too many attempts”问题
  • 调试阶段临时验证:调试时使用AndroidProvider.debug,需确保Firebase控制台的App Check规则允许debug模式下的请求

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 00:01:02