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

VS Code中为Flutter项目集成Firebase时遇版本冲突错误求助

Flutter集成Firebase时Gradle版本冲突问题解决

错误信息

[{
    "resource": "/c:/Users/User/StudioProjects/gp_femuna/android/app/build.gradle.kts",
    "owner": "_generated_diagnostic_collection_name_#5",
    "code": "0",
    "severity": 8,
    "message": "The supplied phased action failed with an exception.\r\nA problem occurred configuring root project 'android'.\r\nBuild file 'C:\\Users\\User\\StudioProjects\\gp_femuna\\android\\build.gradle.kts' line: 1\r\nError resolving plugin [id: 'com.google.gms.google-services', version: '4.4.2', apply: false]\r\nThe request for this plugin could not be satisfied because the plugin is already on the classpath with a different version (4.3.15).",
    "source": "Java",
    "startLineNumber": 1,
    "startColumn": 1,
    "endLineNumber": 1,
    "endColumn": 1
}]

问题原因

Google Services Gradle插件版本冲突:根目录build.gradle.kts中声明使用版本4.4.2,但项目其他依赖已引入旧版本4.3.15,导致Gradle无法解析一致的插件版本。

解决方案

方法1:统一插件版本

将根目录build.gradle.kts中的插件版本改为4.3.15,与冲突版本保持一致:

修改后的根目录build.gradle.kts插件配置部分:

plugins {
  // ...

  // 统一版本为4.3.15
  id("com.google.gms.google-services") version "4.3.15" apply false
}

方法2:强制统一插件版本(可选)

若需保留4.4.2版本,可在根目录build.gradle.kts中添加强制版本配置,确保所有依赖使用指定版本:

plugins {
  // ...
  id("com.google.gms.google-services") version "4.4.2" apply false
}

// 添加强制版本配置
allprojects {
    configurations.all {
        resolutionStrategy {
            force("com.google.gms:google-services:4.4.2")
        }
    }
}

验证步骤

修改完成后执行以下操作确保生效:

  • 运行flutter clean清理项目缓存
  • 重新构建项目flutter run

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 20:45:11