The minCompileSdk (31) specified in a dependency’s AAR metadata is greater than this module’s compileSdkVersion (android-30)

编译Android项目时报如下异常:

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.work:work-runtime:2.7.0.
AAR metadata file: C:\Users\apple\.gradle\caches\transforms-2\files-2.1\6c76dd4d08c29e06352d567fc539f8a4\work-runtime-2.7.0\META-INF\com\android\build\gradle\aar-metadata.properties.

解决方法就是将 compileSdk 和 targetSdk 都由 30 改为 31或者在build.gradle添加如下configurations.all部分的配置:

defaultConfig {
    configurations.all {
        resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
    }
    applicationId "com.xxx.app"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

 

发表回复

后才能评论