Home > front end >  Android Studio error: "6 issues were found when checking AAR metadata"
Android Studio error: "6 issues were found when checking AAR metadata"

Time:01-15

This is a Gradle error which I get when running the empty "hello world" (building from Empty Activity template) without any added code, Here is the error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > 6 issues were found when checking AAR metadata:
 

  1.  Dependency 'androidx.appcompat:appcompat-resources:1.6.0' requires libraries and applications that
      depend on it to compile against version 33 or later of the
      Android APIs.

      :app is currently compiled against android-32.

      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 7.2.0 is 32.

      Recommended action: Update this project's version of the Android Gradle
      plugin to one that supports 33, then update this project to use
      compileSdkVerion of at least 33.

      Note that updating a library or application's compileSdkVersion (which
      allows newer APIs to be used) can be done separately from updating
      targetSdkVersion (which opts the app in to new runtime behavior) and
      minSdkVersion (which determines which devices the app can be installed
      on).

  2.  Dependency 'androidx.appcompat:appcompat:1.6.0' requires libraries and applications that
      depend on it to compile against version 33 or later of the
      Android APIs.

      :app is currently compiled against android-32.

      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 7.2.0 is 32.

      Recommended action: Update this project's version of the Android Gradle
      plugin to one that supports 33, then update this project to use
      compileSdkVerion of at least 33.

      Note that updating a library or application's compileSdkVersion (which
      allows newer APIs to be used) can be done separately from updating
      targetSdkVersion (which opts the app in to new runtime behavior) and
      minSdkVersion (which determines which devices the app can be installed
      on).

I will stop the error messages after these two as I suspect fixing one will fix all six.

Below is my build.gradle (:app)

plugins {
    id 'com.android.application'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.enetapplications.empty"
        minSdk 28
        targetSdk 32
        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
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.6.0'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

This error first occurred while building an app and I was only working with the xml and was ready to begin the java - then for testing I opened a blank "empty" project and received this exact same error thus seems something to do with how Android Studio is being configured.

CodePudding user response:

Update your version to 33 as below

 compileSdk 33

defaultConfig {
    applicationId "com.enetapplications.empty"
    minSdk 28
    targetSdk 33
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

CodePudding user response:

The error message is indicating that the version of the Android SDK that your app is currently compiled against (compileSdk 32) is not compatible with the version of the androidx.appcompat library that you are using (1.6.0). The error message is suggesting that you should update your app's compileSdk version to 33 or later, and update your app to use a compileSdkVersion of at least 33.

To resolve the issue, you can update your app's compileSdk version to 33 or later by modifying the "compileSdk" value in your build.gradle file:

android {
    compileSdk 33
    ...
}

Additionally, you can also update the version of your appcompat library to a newer version, like this:

dependencies {
    implementation 'androidx.appcompat:appcompat:1.8.0'
    ...
}

It's also worth noting that the recommended targetSdk and minSdk version should also be updated to match the compileSdk version.

defaultConfig {
    minSdk 33
    targetSdk 33
    ...
}

After updating the above configurations, clean and rebuild the project and it should work fine.

It's worth noting that this error message is caused by the Android Gradle Plugin 7.2.0, and it is recommend to update the Gradle Plugin to the latest version.

  • Related