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

Firebase测试手机号触发内部错误,寻求解决方案

Firebase Auth "内部错误" 排查与解决(Flutter 3.10.6 + firebase_auth 4.x)

问题场景

旧Firebase项目,配置测试手机号,使用Flutter 3.10.6 + firebase_auth 4.7.2时,突然触发错误:

An internal error has occurred, print and inspect the error details for more information.-

已尝试无效操作:

  • 替换GoogleService-info.plist
  • 删除并重新创建测试账号
  • 禁用后重新启用认证方式
  • 解除Google Cloud密钥的限制
  • 降级firebase_auth至4.4/4.5/4.6/4.7版本

可行排查方案

1. 捕获完整错误信息,定位根因

表面错误无有效信息,必须打印完整异常栈和错误码:

try {
  // 替换为你的手机号登录逻辑
  await FirebaseAuth.instance.signInWithPhoneNumber("+xxx");
} on FirebaseAuthException catch (e) {
  print("Auth错误码: ${e.code}");
  print("错误详情: ${e.message}");
} catch (e) {
  print("未知错误: $e");
}

常见隐藏原因:API配额耗尽、地区服务限制、本地缓存冲突。

2. 检查Firebase API配额

登录Firebase控制台 → 进入目标项目 → 「API和服务」→ 「配额」,搜索Firebase Authentication API,查看是否有超限情况。若超限,可等待配额重置或申请提升。

3. 清理设备本地认证缓存

  • iOS:卸载App → 重启设备 → 重新安装运行
  • Android:设置→应用管理→找到你的App→清除存储/缓存→重启App

4. 验证Auth区域与服务状态

  • 若项目指定了Auth区域,确保Flutter初始化时匹配(或检查控制台区域设置是否变更)
  • 登录Google Cloud控制台→目标项目→「已启用的API和服务」,确认Firebase Authentication API和Identity Toolkit API处于启用状态

5. 统一Firebase依赖版本

确保firebase_core与firebase_auth版本兼容,避免依赖冲突:

dependencies:
  firebase_core: ^2.15.0
  firebase_auth: ^4.7.2

执行flutter pub get更新依赖后重新运行。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 23:10:13