Android Studio 编译报错 The minCompileSdk (33) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
在AS上新建了一个项目,默认的开发语言是kotlin,当项目加载完成后,发现无法编译,并报出如下错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | One or more issues found when checking AAR metadata values: The minCompileSdk ( 33 ) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android- 32 ). Dependency: androidx.core:core: 1.9 . 0 . AAR metadata file: D:\gradle- 6.7 . 1 \caches\transforms- 3 \9f4322093e90d7f81018947ba38ee02c\transformed\core- 1.9 . 0 \META-INF\com\android\build\gradle\aar-metadata.properties. The minCompileSdk ( 33 ) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android- 32 ). Dependency: androidx.core:core-ktx: 1.9 . 0 . AAR metadata file: D:\gradle- 6.7 . 1 \caches\transforms- 3 \48a46785e59c8f4cdfb9c23472b265a8\transformed\jetified-core-ktx- 1.9 . 0 \META-INF\com\android\build\gradle\aar-metadata.properties. The minCompileSdk ( 33 ) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android- 32 ). Dependency: androidx.annotation:annotation-experimental: 1.3 . 0 . AAR metadata file: D:\gradle- 6.7 . 1 \caches\transforms- 3 \68d799915626af8284fc012c9590c9cd\transformed\jetified-annotation-experimental- 1.3 . 0 \META-INF\com\android\build\gradle\aar-metadata.properties. |
如图:
1 2 3 4 5 6 7 8 9 10 | We recommend using a newer Android Gradle plugin to use compileSdk = 32 This Android Gradle plugin ( 7.0 . 3 ) was tested up to compileSdk = 31 This warning can be suppressed by adding android.suppressUnsupportedCompileSdk= 32 to this project's gradle.properties The build will continue , but you are strongly encouraged to update your project to use a newer Android Gradle Plugin that has been tested with compileSdk = 32 |
如图:
解决:
这边报错原因是’androidx.appcompat:appcompat:1.5.1’ 版本过高,在此降低依赖库的版本即可,使用’androidx.appcompat:appcompat:1.0.0’,这样“Sync now”后,代码上的红色下划线便消失了。
现在的版本:
1 2 3 4 5 6 7 | implementation 'androidx.core:core-ktx:1.9.0' implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' |
我直接用的以前项目的版本
1 2 3 4 5 6 7 | implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'com.google.android.material:material:1.5.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'org.jetbrains:annotations:15.0' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' |
再次编译,OK,可以正常编译
参考:https://blog.csdn.net/qq_39994562/article/details/126744988
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· Vue3状态管理终极指南:Pinia保姆级教程