Android 工程编译时报错 :
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> 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.appcompat:appcompat:1.4.1.
AAR metadata file: C:\Users\octop\.gradle\caches\transforms-2\files-2.1\1545d05330b91959e9302573f67dc81d\appcompat-1.4.1\META-INF\com\android\build\gradle\aar-metadata.properties.
Android 工程中的 Module 的 build.gradle 中配置如下内容 :
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "kim.hsl.paintgradient"
minSdkVersion 18
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}
androidx.appcompat:appcompat:1.4.1 依赖库的 minCompileSdk 是 31 , 因此本应用应该使用 31 版本的 SDK 和 工具 ;
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
}
Android 工程中的 Module 的 build.gradle 中配置修成如下即可成功编译 :
android {
compileSdkVersion 31
buildToolsVersion "31.0.0"
defaultConfig {
applicationId "kim.hsl.paintgradient"
minSdkVersion 18
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}