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

Cordova环境配置Android SDK 33栈时构建失败求助

Cordova Android构建错误:mapDebugSourceSetPaths任务失败解决指南

问题背景

  • 开发环境:Cordova + Android Build Tools 33.0.0 + Gradle 7.6(环境变量已配置验证)
  • Android平台版本:12.0.0(targetSdkVersion 33)
  • 核心插件:cordova-plugin-firebasex 16.0.0
  • 执行cordova run android时触发以下错误:
Execution failed for task ':app:mapDebugSourceSetPaths'.
> Error while evaluating property 'extraGeneratedResDir' of task ':app:mapDebugSourceSetPaths'.
   > Failed to calculate the value of task ':app:mapDebugSourceSetPaths' property 'extraGeneratedResDir'.
      > Querying the mapped value of provider(java.util.Set) before task ':app:processDebugGoogleServices' has completed is not supported

解决方案

1. 升级cordova-plugin-firebasex到兼容版本

当前16.0.0版本与Gradle 7.6、Android 12.0.0存在任务依赖兼容性问题,直接升级到最新稳定版:

cordova plugin remove cordova-plugin-firebasex
cordova plugin add cordova-plugin-firebasex@latest

2. 手动调整Gradle任务依赖(临时修复)

若无法立即升级插件,可修改Android平台的Gradle配置,强制指定任务执行顺序:

  • 打开platforms/android/app/build.gradle文件
  • 在文件末尾添加以下代码:
tasks.named('mapDebugSourceSetPaths') {
    mustRunAfter 'processDebugGoogleServices'
}
tasks.named('mapReleaseSourceSetPaths') {
    mustRunAfter 'processReleaseGoogleServices'
}

注意:每次重新添加Android平台后需重新配置

3. 验证Google Services插件版本

确保platforms/android/build.gradle中com.google.gms:google-services版本兼容Gradle 7.6,建议使用4.3.15及以上:

dependencies {
    classpath 'com.google.gms:google-services:4.3.15'
}

4. 清理构建缓存后重新构建

cordova clean android
cordova run android

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 02:06:04