如何解决Kotlin中依赖AAR元数据minCompileSdk高于模块compileSdk的错误?
解决AAR元数据minCompileSdk冲突问题
方法一:升级模块的compileSdkVersion到33
将模块build.gradle中的compileSdk和targetSdk都改为33,匹配依赖要求的最低编译版本:
plugins { id 'com.android.application' id 'kotlin-android' } android { compileSdk 33 defaultConfig { applicationId "com.example.aboutme" minSdk 19 targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } }
方法二:降级androidx.core依赖到兼容版本
如果暂时不想升级compileSdk,可将androidx.core:core的版本降级到1.8.0(该版本minCompileSdk为31,兼容当前的32)。在模块的dependencies块中指定具体版本:
dependencies { implementation 'androidx.core:core:1.8.0' // 其他依赖... }
若项目未显式声明
androidx.core:core,大概率是其他依赖间接引入了1.9.0版本。可通过Gradle命令./gradlew app:dependencies(Windows系统用gradlew.bat app:dependencies)查看依赖树,定位到相关引用后添加上述强制版本声明即可。
内容的提问来源于stack exchange,提问作者vijendra kumar
相关产品推荐
相关产品推荐

