Tanya Gupta
Tanya Gupta

Reputation: 67

How should I resolve the error The minCompileSdk (31) specified in a dependency's AAR metadata?

How should I resolve the error The minCompileSdk (31) specified in a dependency's AAR metadata ?

I am getting the error :

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.0. AAR metadata file: C:\Users\DELL.gradle\caches\transforms-2\files-2.1\f791a17b4bc4281a7d6408e3f7005919\appcompat-1.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.

enter image description here

This is my build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

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

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
}

I have even tried changing the version from 30 to 31, but again it shows the error:

    "Installed Build Tools revision 31.0.0 is corrupted"

How should I fix this error ?

Upvotes: 1

Views: 7904

Answers (1)

Encycode
Encycode

Reputation: 783

Add this code in build.gradle(app)

configurations.all {
  resolutionStrategy {
    force 'androidx.appcompat:appcompat:1.3.1'
  }
}

Upvotes: 2

Related Questions