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

Flutter项目构建提示需更新firebase_core依赖已装对应版本仍报错如何解决

Flutter 项目构建异常解决方案

错误1:firebase_core 版本不兼容

你当前使用的 cloud_firestore 2.5.2 要求 firebase_core 最低版本为 1.10.0,现有 1.6.0 版本未达最低要求,此前能正常运行是依赖缓存未触发版本校验导致。
处理步骤:

  • 调整 pubspec.yaml 中所有 Firebase 系列依赖到兼容版本,参考配置如下:
dependencies:
  # 其余原有依赖保持不变
  cloud_firestore: ^2.5.4
  cloud_functions: ^3.2.1
  firebase_auth: ^3.3.0
  firebase_core: ^1.10.0
  firebase_crashlytics: ^2.4.0
  firebase_messaging: ^10.0.9
  • 执行如下命令清理旧依赖缓存、拉取新依赖:
flutter clean
rm pubspec.lock
flutter pub get

错误2:compileSdkVersion 未指定

该错误由安卓项目配置缺失导致,处理步骤:

  • 打开项目目录下 android/app/build.gradle 文件
  • 修改 android 配置块,新增/调整 compileSdkVersion 为 31 及以上,参考配置:
android {
    compileSdkVersion 31
    defaultConfig {
        // 保留原有其他配置
        minSdkVersion 19
        targetSdkVersion 31
    }
}

可选校验步骤

如果修改后仍报错,检查项目根目录下 android/build.gradle,确保仓库配置包含 google 源:

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

完成上述操作后重新运行项目即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.03 18:15:02