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

Flutter集成Firebase构建失败:mapDebugSourceSetPaths任务报错

解决Flutter Firebase集成时的:app:mapDebugSourceSetPaths构建错误

这个错误的核心原因是Google Services Gradle插件版本与Android Gradle插件(AGP)版本不兼容——你使用的AGP是7.3.0,但搭配的google-services插件4.3.10版本过低,导致任务执行顺序冲突。

修复步骤:

  1. 升级Google Services插件版本
    修改项目根目录下build.gradle中的依赖配置,将google-services版本升级到与AGP 7.3.0兼容的版本(推荐4.3.15及以上):

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        // 升级后的Google Services插件版本
        classpath 'com.google.gms:google-services:4.3.15'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
    
  2. 匹配Gradle Wrapper版本
    打开gradle/wrapper/gradle-wrapper.properties文件,确保Gradle版本与AGP 7.3.0匹配(要求Gradle 7.4及以上):

    distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
    
  3. 清理并重建项目
    执行以下命令彻底清理缓存后重新构建:

    flutter clean
    rm -rf android/.gradle android/build
    flutter pub get
    

    之后再次尝试运行Flutter应用即可。

额外提示

新手集成Firebase时,务必注意AGP、Gradle、Google Services这三者的版本兼容性,建议参考FlutterFire官方文档的版本对应说明,避免因版本不匹配导致的构建问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 05:52:39