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

FlutterFire配置失败求助:Firebase CLI相关异常问题

解决FlutterFire Configure命令的两类异常

问题1:Firebase CLI内执行flutterfire configure提示未安装Firebase CLI

报错信息

> flutterfire configure --project=provexmmobile
i Found 0 Firebase projects. Selecting project provexmmobile.
FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command.
COMMAND: firebase --version
ERROR: The FlutterFire CLI currently requires the official Firebase CLI to also be installed, see https://firebase.google.com/docs/cli#install_the_firebase_cli for how to install it.

解决步骤

  • 检查Firebase CLI环境变量:确保Firebase CLI的安装路径已添加到系统PATH,在普通CMD/PowerShell终端直接执行firebase --version验证命令可正常运行。
  • 重启所有终端窗口:修改环境变量后必须重启终端,确保新配置生效。
  • 重新关联Firebase账号:执行firebase logout后再执行firebase login,确认账号能正常访问目标项目provexmmobile。

问题2:CMD执行flutterfire configure抛出FormatException

报错信息

flutterfire configure --project=provexmmobile
⠼ Fetching available Firebase projects...
Unhandled exception:
FormatException: Unexpected character (at character 1)
#
^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1383:5)
#1      _ChunkedJsonParser.parseNumber (dart:convert-patch/convert_patch.dart:1250:9)
#2      _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:915:22)
#3      _parseJson (dart:convert-patch/convert_patch.dart:35:10)
#4      JsonDecoder.convert (dart:convert/json.dart:610:36)
#5      runFirebaseCommand (package:flutterfire_cli/src/firebase.dart:95:25)
<asynchronous suspension>
#6      getProjects (package:flutterfire_cli/src/firebase.dart:114:20)
<asynchronous suspension>
#7      ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:300:24)
<asynchronous suspension>
#8      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:390:37)
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#10     main (file:///C:/Users/hao/AppData/Local/Pub/Cache/hosted/pub.dev/flutterfire_cli-0.2.7/bin/flutterfire.dart:57:5)
<asynchronous suspension>

解决步骤

该异常是FlutterFire CLI解析Firebase命令输出失败导致,通常是输出混入非JSON内容,按以下步骤排查:

  1. 清理Firebase缓存:删除用户目录下的.firebase文件夹(Windows路径:C:\Users\[你的用户名]\.firebase),之后重新执行firebase login。
  2. 升级FlutterFire CLI:当前使用的0.2.7版本较旧,执行命令升级:
    dart pub global activate flutterfire_cli
    
  3. 跳过交互直接配置:尝试直接指定项目并跳过项目列表拉取:
    flutterfire configure --project=provexmmobile --no-interactive
    
  4. 切换终端编码:CMD默认编码可能导致解析异常,先执行切换编码命令:
    chcp 65001
    
    再运行flutterfire configure。

通用验证步骤

  • 执行flutterfire doctor确认所有依赖状态正常。
  • 执行firebase projects:list验证能否正常列出Firebase项目,确保provexmmobile在列表内。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 15:37:43