Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve this error The minCompileSdk (31) specified in a dependency's AAR metadata in native java/kotlin? [duplicate]

The error message:

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.core:core-ktx:1.7.0-alpha02.

AAR metadata file:
C:\Users\mohammad.zeeshan1.gradle\caches\transforms-2\files-2.1\a20beb0771f59a8ddbbb8d416ea06a9d\jetified-core-ktx-1.7.0-alpha02\META-INF\com\android\build\gradle\aar-metadata.properties.

like image 804
Mohammad Zeeshan Avatar asked Sep 02 '21 17:09

Mohammad Zeeshan


3 Answers

Set both compileSdkVersion and targetSdkVersion to 31 in your build.gradle(app) file.

android {
    compileSdkVersion 31 // <-- This
    defaultConfig {
        applicationId "com.example.app"
        targetSdkVersion 31 // <-- and this too
        // ...
    }
}
like image 110
CopsOnRoad Avatar answered Oct 19 '22 05:10

CopsOnRoad


I have found the solution. Enter this line of code above package in the app Gradle file.

For Kotlin developers:

configurations.all {
    resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}

Screenshot of code with a red freehand circle

For Java developers

configurations.all {
    resolutionStrategy { force 'androidx.core:core:1.6.0' }
}
like image 139
Mohammad Zeeshan Avatar answered Oct 19 '22 07:10

Mohammad Zeeshan


This issue is most often seen with libraries that declare

implementation androidx.core:core-ktx:1.7.0-beta01

The minCompileSdk is 31, but the minSdkVersion is significantly lower.

Increasing the compileSdk of your project is enough to fix the issue. There is no need for overrides or even changing the targetSdk.

android {
    compileSdk 31

...
}
like image 60
Abandoned Cart Avatar answered Oct 19 '22 05:10

Abandoned Cart