检查AAR元数据时发现24个问题,请求技术协助
解决AAR元数据检查错误与编译SDK版本冲突问题
方案1:降级依赖版本适配现有compileSdk 33
- 把
androidx.navigation:navigation-common从2.7.0降到2.6.0,这个版本完全兼容compileSdk 33 - Compose系列库降到1.5.x分支,比如1.5.4,该分支不需要compileSdk 34
- 模块build.gradle依赖修改示例:
dependencies { // Navigation相关 implementation 'androidx.navigation:navigation-common:2.6.0' implementation 'androidx.navigation:navigation-compose:2.6.0' // Compose相关 implementation 'androidx.compose.ui:ui:1.5.4' implementation 'androidx.compose.material3:material3:1.1.2' implementation 'androidx.compose.ui:ui-tooling-preview:1.5.4' }
方案2:升级AGP版本以支持compileSdk 34
Android Gradle插件8.2.0及以上版本已经支持compileSdk 34,操作步骤:
- 修改项目根目录
build.gradle里的AGP版本:
buildscript { dependencies { classpath 'com.android.tools.build:gradle:8.2.0' } }
- 调整模块
build.gradle的compileSdk和targetSdk:
android { compileSdk 34 defaultConfig { targetSdk 34 } }
- 同步Gradle后,就能保留原本的高版本依赖(navigation 2.7.0、Compose 1.6+等)正常构建
方案3:临时跳过AAR元数据检查(仅临时调试用)
如果前两个方案暂时无法落地,可以临时关闭检查,但可能埋下兼容性隐患,谨慎使用:
在模块build.gradle中添加:
android { lintOptions { abortOnError false checkReleaseBuilds false } }
或者更精准地针对冲突依赖调整属性:
android { dependencies { constraints { all { if (it.group == 'androidx.navigation' || it.group.startsWith('androidx.compose')) { attributes { attribute('android.compileSdkVersion', '33') } } } } } }
内容的提问来源于stack exchange,提问作者Tope
相关产品推荐
相关产品推荐

