构建安卓项目时出现‘检查AAR元数据发现2个问题’的求助
解决AAR Metadata检查错误的方案
1. 移除重复依赖
你的dependencies块中存在重复的androidx.core:core-ktx依赖:
implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.core:core-ktx:+'
+会自动拉取该库的最新版本,而最新版本可能要求更高的minSdk(高于你项目设置的31),从而触发AAR metadata检查错误。删除其中一行,保留固定版本的依赖:
dependencies { implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.9.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' }
2. 移除不必要的buildToolsVersion配置
buildToolsVersion '33.0.0'可以直接删除,Android Studio会根据你的compileSdk 33自动匹配对应的构建工具版本,手动指定反而可能引发版本不兼容问题。
3. 同步并清理项目
- 点击Android Studio工具栏的
Sync Project with Gradle Files按钮同步项目 - 依次执行
Build > Clean Project和Build > Rebuild Project清理并重新构建项目
如果以上步骤仍未解决问题,可检查每个依赖的minSdk要求是否与项目的minSdk 31兼容:
- 打开
File > Project Structure > Dependencies,查看每个依赖的详细信息,确认其minSdk不高于31 - 若存在依赖的
minSdk高于31,要么升级项目的minSdk到对应版本,要么降级该依赖到适配minSdk 31的版本
内容的提问来源于stack exchange,提问作者Sahran
相关产品推荐
相关产品推荐

