The minCompileSdk (31) specified

Viewed 10248
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.
5 Answers

As mentioned in the error message, if you use androidx.core:core-ktx:1.7.0-alpha02, your compileSdk needs to be at least 31 and you have 30 there.

Either update the compile SDK version or use an older version of the core-ktx dependency.

Add this line of code in-app `build.gradle file.

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

Change compileSdkVersion and targetSdkVersion to 31 in build.gradle(app)

android {
    compileSdkVersion 31 // <-- HERE
    defaultConfig {
        applicationId "com.your.package"
        targetSdkVersion 31 // <-- AND HERE
    }
}

I had the same problem here, in my case solved it by changing

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'

to

implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'

if you don't want to downgrade, you can upgrade the compile and targetSdkVersion to 31 as @Hardik Hirpara mention

Simply change the compileSdk to 31 and targetSdk to 31

Related