3

I started to learn Kotlin with Jetpack compose since the UI building looks easy to get into since I've done Flutter before. But I am unable to start my development. I keep on getting the same error right from the beginning. The error is mentioned below.

One or more issues found when checking AAR metadata values:

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.activity:activity-compose:1.4.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/17c0065263b1ac8274468d1f294bb3f1/transformed/jetified-activity-compose-1.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

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.activity:activity-ktx:1.4.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/f6dca3ff903d8b71dc31289976e22565/transformed/jetified-activity-ktx-1.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

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.lifecycle:lifecycle-runtime-ktx:2.4.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/7d4cb7a963f721e0466a4f4713a2cbb9/transformed/jetified-lifecycle-runtime-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

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.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/89719b86a3bdb3906dcc70f7ccde2945/transformed/jetified-core-ktx-1.7.0/META-INF/com/android/build/gradle/aar-metadata.properties.

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.activity:activity:1.4.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/73d6a039b3ae7c3afc83ef08e89d1421/transformed/jetified-activity-1.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

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:1.7.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/acb209d88ce91ed7fb4d20f7c42190d1/transformed/core-1.7.0/META-INF/com/android/build/gradle/aar-metadata.properties.

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.lifecycle:lifecycle-runtime:2.4.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/112ed6ed65dc4f7ca288781673eb239c/transformed/lifecycle-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

My gradle looks like so

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdk 30

    defaultConfig {
        applicationId "com.example.kotlinbegginner"
        minSdk 26
        targetSdk 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    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'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion '1.5.21'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
    implementation 'androidx.activity:activity-compose:1.4.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
}

Can anyone explain why this is happening and how to solve it? Any help will be appreciated! Thanks in advance :)

Rohit Varma
  • 277
  • 1
  • 4
  • 10
  • 1
    Change **Compile SDK** to 31 in your `build.gradle` file. And also **targetSdk** to 31. – Vaibhav Goyal Nov 15 '21 at 10:21
  • 1
    Does this answer your question? [Android app won't build -- The minCompileSdk (31) specified in a dependency's androidx.work:work-runtime:2.7.0-beta01](https://stackoverflow.com/questions/69037481/android-app-wont-build-the-mincompilesdk-31-specified-in-a-dependencys-an) – Stefano Sansone Nov 15 '21 at 13:20

1 Answers1

0

change this line in your gradle file:

composeOptions {
        kotlinCompilerExtensionVersion compose_version
 
--->    kotlinCompilerVersion '1.5.21'  <---
    
    }

to this:

kotlinCompilerVersion '1.5.31'

And in your build.gradle (Project)

change this line:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"

to this:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
helpinghand
  • 169
  • 9