升级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
- 手动删除Gradle缓存目录:
强制指定稳定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重新下载完整资源
- 找到本地仓库中该aar的存储路径:
禁用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
相关产品推荐
相关产品推荐

