4

I am making a release build for my project using ./gradlew assembleRelease command but it gives me this error.

> Task :app:checkReleaseAarMetadata FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkReleaseAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > 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-alpha02.
     AAR metadata file: /Users/classic/.gradle/caches/transforms-2/files-2.1/64ba04558e5775ef86bc1e2e88b04a01/core-1.7.0-alpha02/META-INF/com/android/build/gradle/aar-metadata.properties.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

I cannot edit my build.gradle for fixing this error as project has some dependencies that break after changing compileSdkVersion.

Edit
I added the following line to my android/app/build.gradle but that didn't worked for me.

implementation "androidx.core:core-ktx:1.6.0"

Related issue -> here

Rohit Aggarwal
  • 1,048
  • 1
  • 14
  • 32
  • 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) – Zoe Sep 24 '21 at 14:12
  • Thanks for your answer @Zoe. I have fixed using the accepted answer. – Rohit Aggarwal Sep 25 '21 at 05:02

2 Answers2

6

Finally I have fixed this error by adding the following line to android/build.gradle.

buildscript {
    ext {
        androidXCore = "1.6.0" // <-- Add this line
        buildToolsVersion = "29.0.3"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 29
        ndkVersion = "20.1.5948944"
    }
Rohit Aggarwal
  • 1,048
  • 1
  • 14
  • 32
1

i was using old RN, so i upgraded then it worked for me. i did below changes. gradle clean, run the app

package.json

"react-native": "0.67.4", // previous 0.62.3
"react-native-reanimated": "^2.8.0", // previous "1.13.0",

android\gradle\wrapper\gradle-wrapper.properties // previous 6.1.1

distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

android\build.gradle

buildscript {
    ext {
        buildToolsVersion = "30.0.2" // previous "29.0.2"
        minSdkVersion = 23
        compileSdkVersion = 30 // 29 previous
        targetSdkVersion = 30 // previous 29      
    }
...
}

   dependencies {
        classpath('com.android.tools.build:gradle:4.2.2')
___
    }

allprojects {
    repositories {
        exclusiveContent {
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
       }
    . . . 
    }
    }
Ragu
  • 51
  • 4