Android Studio 编译报错 The minCompileSdk (33) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
在AS上新建了一个项目,默认的开发语言是kotlin,当项目加载完成后,发现无法编译,并报出如下错误:
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.
如图:
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”后,代码上的红色下划线便消失了。
现在的版本:
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'
我直接用的以前项目的版本
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