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

Android Studio修改target SDK至33后报错的解决方法咨询

解决 targetSdkVersion 33 下的 Gradle 任务执行错误

翻译后的错误内容

任务 ':app:mapDebugSourceSetPaths' 执行失败。
> 评估任务 ':app:mapDebugSourceSetPaths' 的 'extraGeneratedResDir' 属性时出错
   > 无法计算任务 ':app:mapDebugSourceSetPaths' 的 'extraGeneratedResDir' 属性值。
      > 不支持在任务 ':app:processDebugGoogleServices' 完成前查询 provider(java.util.Set) 的映射值

* 尝试:
> 使用 --info 或 --debug 选项运行以获取更多日志输出。
> 使用 --scan 运行以获取完整分析信息。

* 异常信息:
org.gradle.api.tasks.TaskExecutionException: 任务 ':app:mapDebugSourceSetPaths' 执行失败。
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:38)

可行解决步骤

  • 更新Google Services插件版本:在项目根目录的build.gradle文件中,将com.google.gms:google-services插件更新至最新稳定版(如4.4.0及以上),旧版本与targetSdk33的Gradle任务兼容性较差。
  • 调整任务依赖关系:在app模块的build.gradle中添加任务依赖,确保mapDebugSourceSetPaths在processDebugGoogleServices完成后执行:
    tasks.named('mapDebugSourceSetPaths') {
        mustRunAfter 'processDebugGoogleServices'
    }
    tasks.named('mapReleaseSourceSetPaths') {
        mustRunAfter 'processReleaseGoogleServices'
    }
    
  • 清理Gradle缓存:执行以下命令清除缓存后重新构建:
    ./gradlew clean build --refresh-dependencies
    
  • 检查Android Gradle插件版本:确保项目使用的Android Gradle插件(AGP)版本与targetSdk33兼容,比如AGP 7.4.0及以上版本对targetSdk33支持更完善,在根目录build.gradle中更新:
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 22:27:06