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

升级Android Studio至API 36后AAPT2编译错误求助

修复API 36适配后AAPT2资源解析错误方案
  • 清理本地缓存

    • 手动删除Gradle缓存目录:
      Windows路径:C:\Users\<你的用户名>\.gradle\caches 和 C:\Users\<你的用户名>\.android\build-cache
      Mac路径:~/Library/Caches/gradle 和 ~/Library/Caches/AndroidStudio<版本号>/build-cache
    • 打开Android Studio,执行 File > Invalidate Caches...,勾选Clear file system cache and local history后点击Invalidate and Restart
  • 强制指定稳定AAPT2版本
    在项目根目录的build.gradle(Project级)中添加固定版本配置:

    buildscript {
        repositories {
            google()
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:8.4.0'
            classpath 'com.android.tools.build:aapt2:7.4.0-7447869'
        }
    }
    
  • 重新下载损坏的core-1.13.1.aar包

    • 找到本地仓库中该aar的存储路径:~/.gradle/caches/modules-2/files-2.1/androidx.core/core/1.13.1/
    • 删除该目录下所有文件,然后在终端执行 ./gradlew clean build --refresh-dependencies 让Gradle重新下载完整资源
  • 禁用AAPT2守护进程
    在app模块的build.gradle中添加以下配置:

    android {
        ...
        aaptOptions {
            noDaemon = true
        }
    }
    
  • 检查JDK版本
    确保使用JDK 17,在Android Studio中通过File > Project Structure > SDK Location > JDK Location选择Embedded JDK 17

内容的提问来源于stack exchange,提问作者Helcio Ramos de Lima

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 10:24:52