Vivek Modi
Vivek Modi

Reputation: 7151

One or more issues found when checking AAR metadata values:

Hey I am trying to run my application and I am getting this error

build.gradle

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

android {
    compileSdk 30

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

    defaultConfig {

        applicationId "com.example.listadapter"
        minSdk 21
        targetSdk 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'
    }

    buildFeatures {
        viewBinding true
    }
}

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.constraintlayout:constraintlayout:2.1.1'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation "com.squareup.retrofit2:converter-moshi:2.5.0"
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'

    implementation "com.squareup.moshi:moshi:1.12.0"
    implementation "com.squareup.moshi:moshi-kotlin:1.12.0"

    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
    implementation "android.arch.lifecycle:extensions:1.1.1"
    implementation 'androidx.fragment:fragment-ktx:1.3.6'
}

I tried this All Example from this link it's not working

getting error after installing the application. I just created a new application. I don't understand why this is causing it. Does anyone know how to solve this problem? Thanks in adavance.

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.lifecycle:lifecycle-viewmodel-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/b7f9608e476cb2e496993f185af8912c/transformed/jetified-lifecycle-viewmodel-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.lifecycle:lifecycle-runtime-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/538fea46e89a6c8a3e3eec533224abb8/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.lifecycle:lifecycle-livedata-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/6a1f77e99280b09902894e4ae8301047/transformed/jetified-lifecycle-livedata-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.lifecycle:lifecycle-viewmodel:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/41cf6125c3fd7a33d28222cf07d20520/transformed/lifecycle-viewmodel-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.lifecycle:lifecycle-runtime:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/655163560a267a5b16e2f66044d78641/transformed/lifecycle-runtime-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.lifecycle:lifecycle-livedata:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/1ca84d966e72f2f06b580da1765a55a5/transformed/lifecycle-livedata-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.lifecycle:lifecycle-livedata-core-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/3ed4d52253be7f6d85cbabee72c886d3/transformed/jetified-lifecycle-livedata-core-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.lifecycle:lifecycle-livedata-core:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/4e8a32482e233cfbbc450e03aabed8dd/transformed/lifecycle-livedata-core-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

If i change my compileSdk 31 it gives me another error.

Could not resolve all files for configuration ':app:androidApis'.
Failed to transform android.jar to match attributes {artifactType=android-mockable-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, returnDefaultValues=false}.
Execution failed for MockableJarTransform: /Users/vmodi/Library/Android/sdk/platforms/android-31/android.jar.
Cannot create mockable android.jar
/Users/vmodi/Library/Android/sdk/platforms/android-31/android.jar

Upvotes: 31

Views: 94486

Answers (9)

hema ezzat
hema ezzat

Reputation: 567

Change your compileSdk to 33 (or whatever the latest happens to be now).

compileSdk 33

defaultConfig {
    applicationId "com.example.lifecycle"
    minSdk 21
    targetSdk 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Upvotes: 38

Syed Mohammad Yasir
Syed Mohammad Yasir

Reputation: 21

compileSdk and targetSdk both should be 31.

Upvotes: 2

Aditya Jain
Aditya Jain

Reputation: 11

The issue is with this dependency:

androidx.lifecycle:lifecycle-runtime-ktx:2.4.0

There may be some transitive dependency error. I would suggest use the alpha version of this dependency which worked for me.

Replace with this dependency:

androidx.lifecycle:lifecycle-*:2.4.0-alpha03

Upvotes: 1

Mick
Mick

Reputation: 681

When I got this error, I had just made two changes in build.gradle/app so I undid them, error went away. Here are the two statements with the arrow pointing to the previous value that I restored:

implementation 'androidx.core:core:1.12.0' -> 1.10.1

implementation 'androidx.annotation:annotation:1.7.0' -> 1.6.0

Upvotes: 0

user20372118
user20372118

Reputation: 1

Every time I ran my application, the AAR metadata would give me an error, so I did this to fix it:

  1. Go to the left side of the screen and there's an option called "Gradle Scripts".
  2. Click on it and there will be many options
  3. Click on the second one that says "build.gradle` module"
  4. Go to the last method named "dependencies" 5 In the method there is a line:
    implementation 'androidx.appcompat:appcompat:1.5.1'
    
    so delete the :1.5.1 so the line becomes:
    implementation 'androidx.appcompat:appcompat'
    

Upvotes: 0

Md. Suhel Arman Khan
Md. Suhel Arman Khan

Reputation: 71

Just remove one dependencies from your Gradle Scripts, then it will be solved.

  1. Open your build.gradle(:app)
  2. Go to dependencies
  3. Remove implementation 'androidx.appcompat:appcompat:1.6.0'

After doing this the problem was solved for me.

Upvotes: 1

Aishwarya
Aishwarya

Reputation: 361

Try to downgrade Kotlin library. I have changed

implementation 'androidx.core:core-ktx:1.9.0'

to

implementation 'androidx.core:core-ktx:1.8.0'

and this resolved my error.

Upvotes: 2

Wasim
Wasim

Reputation: 1140

For me setting these two values to API 31 worked

commonCompileSdkVersion = 31
commonTargetSdkVersion = 31

Upvotes: 1

user1373996
user1373996

Reputation:

This is because you just upgraded Kotlin.

Open SDK Manager, install Android 12 (API 31) or above, then change compileSdkVersion to 31 (or above) and change targetSdkVersion to 31 (or above).

Then you will need to change minSdkVersion to 19 as well.

Upvotes: 1

Related Questions