创建项目后重启Android Studio出现无法解析aapt2:7.3.1-8691043错误求助
解决Android Studio重启后找不到aapt2依赖的问题
问题描述
创建新项目时可正常运行,但退出Android Studio重新打开后,出现如下构建错误:
Execution failed for task ':app:processDebugResources'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Failed to transform material-1.7.0.aar (com.google.android.material:material:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Could not isolate parameters com.android.build.gradle.internal.dependency.AarResourcesCompilerTransform$Parameters_Decorated@8d32791 of artifact transform AarResourcesCompilerTransform > Could not isolate value com.android.build.gradle.internal.dependency.AarResourcesCompilerTransform$Parameters_Decorated@8d32791 of type AarResourcesCompilerTransform.Parameters > Could not resolve all files for configuration ':app:detachedConfiguration2'. > Could not find com.android.tools.build:aapt2:7.3.1-8691043. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/7.3.1-8691043/aapt2-7.3.1-8691043.pom - https://repo.maven.apache.org/maven2/com/android/tools/build/aapt2/7.3.1-8691043/aapt2-7.3.1-8691043.pom Required by: project :app
环境信息
- Android Studio Dolphin
- Android Gradle Plugin版本7.3.1
- Gradle版本7.4
解决方法
1. 确保Google Maven仓库已配置
aapt2仅发布在Google Maven仓库,需检查项目根目录的build.gradle文件,确认repositories块包含google():
buildscript { repositories { google() // 必须添加 mavenCentral() } // 其他构建脚本配置 } allprojects { repositories { google() // 必须添加 mavenCentral() } }
2. 清理缓存并重新同步项目
- 点击Android Studio顶部菜单栏
File→Invalidate Caches... - 勾选
Invalidate and Restart,等待IDE重启 - 重启完成后,点击
File→Sync Project with Gradle Files
3. 手动指定aapt2版本
若上述方法无效,可在项目根目录的gradle.properties文件中添加以下配置,强制指定aapt2版本:
android.aapt2Version=7.3.1-8691043
添加后重新同步项目即可。
内容的提问来源于stack exchange,提问作者NoName
相关产品推荐
相关产品推荐

