35

I have o change the mincompilesdkversion to 30 and then again to 29 now I am getting this error.

 A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (30) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.appcompat:appcompat:1.4.0-alpha03.
        AAR metadata file: C:\Users\dell\.gradle\caches\transforms-2\files-2.1\75e2de9081ba66388e83ea28d3fd2da1\appcompat-1.4.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (30) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.appcompat:appcompat-resources:1.4.0-alpha03.
        AAR metadata file: C:\Users\dell\.gradle\caches\transforms-2\files-2.1\290cdab22c9c5b1b7c3f8650a9e9566d\jetified-appcompat-resources-1.4.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (30) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.emoji2:emoji2-views-helper:1.0.0-alpha03.
        AAR metadata file: C:\Users\dell\.gradle\caches\transforms-2\files-2.1\c885669bddbda30b297932769f58904c\jetified-emoji2-views-helper-1.0.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (30) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.emoji2:emoji2:1.0.0-alpha03.
        AAR metadata file: C:\Users\dell\.gradle\caches\transforms-2\files-2.1\078363885b7b4397f6f0ba1e544abc8e\jetified-emoji2-1.0.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (30) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.core:core:1.7.0-alpha01.
        AAR metadata file: C:\Users\dell\.gradle\caches\transforms-2\files-2.1\805c250fb9ce03c9ddefabde06af7912\core-1.7.0-alpha01\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.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Multiple task action failures occurred:
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (30) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.appcompat:appcompat:1.4.0-alpha03.
        AAR metadata file: C:\Users\dell\.gradle\caches\transforms-2\files-2.1\75e2de9081ba66388e83ea28d3fd2da1\appcompat-1.4.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (30) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.appcompat:appcompat-resources:1.4.0-alpha03.
        AAR metadata file: C:\Users\dell\.gradle\caches\transforms-2\files-2.1\290cdab22c9c5b1b7c3f8650a9e9566d\jetified-appcompat-resources-1.4.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (30) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.emoji2:emoji2-views-helper:1.0.0-alpha03.
        AAR metadata file: C:\Users\dell\.gradle\caches\transforms-2\files-2.1\c885669bddbda30b297932769f58904c\jetified-emoji2-views-helper-1.0.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (30) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.emoji2:emoji2:1.0.0-alpha03.
        AAR metadata file: C:\Users\dell\.gradle\caches\transforms-2\files-2.1\078363885b7b4397f6f0ba1e544abc8e\jetified-emoji2-1.0.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (30) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.core:core:1.7.0-alpha01.
        AAR metadata file: C:\Users\dell\.gradle\caches\transforms-2\files-2.1\805c250fb9ce03c9ddefabde06af7912\core-1.7.0-alpha01\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.

* Get more help at https://help.gradle.org
3
  • Did you trie to clean the build? From android studio/build/Clean Project Commented Jul 2, 2021 at 7:55
  • yes. i have finally solved this issue. Commented Jul 2, 2021 at 7:58
  • @megachill there are many issue in the project. some were done by changing sdk and other dependency versions. but that is a headache. if your. project is small then simply create new project, install latest dependencies ad copy your source code to that. it may take a day or two but for niece one year updates will be easy. Commented Oct 17, 2023 at 4:14

11 Answers 11

31

If you are coming here after Nov 4/22 where react native released 0.71.0-rc0 and you are unable to build your android project as i was follow this.

📢 Patches for >= 0.63 Releases for all the main versions of react-native with an hotfix:

🛳 0.70.5: https://github.com/facebook/react-native/releases/tag/v0.70.5

🛳️ 0.69.7: https://github.com/facebook/react-native/releases/tag/v0.69.7

🛳 0.68.5: https://github.com/facebook/react-native/releases/tag/v0.68.5

🛳️ 0.67.5: https://github.com/facebook/react-native/releases/tag/v0.67.5

🛳️ 0.66.5: https://github.com/facebook/react-native/releases/tag/v0.66.5

🛳️ 0.65.3: https://github.com/facebook/react-native/releases/tag/v0.65.3

🛳️ 0.64.4: https://github.com/facebook/react-native/releases/tag/v0.64.4

🛳️ 0.63.5: https://github.com/facebook/react-native/releases/tag/v0.63.5

By updating to these patch versions, your Android build should start working again.

To do so, in your package.json change react-native's version to the relevant new patch (ex. if you are on 0.64.3, change to 0.64.4) and run yarn install. No other changes should be necessary, but you might want to clean your android artifacts with a cd android && ./gradlew clean before trying to re-run your Android app.

Fix for older react-native (< 0.63) The fix above only works on gradle 6.2 and higher. Older react-native used older gradle.

You may determine your gradle version by looking in your /android/gradle/wrapper/gradle-wrapper.properties file.

If you are on an older version of react-native (for example 0.63 or earlier) that uses gradle version 6.1 or below, you must use a different workaround as gradle 6.1 does not support exclusiveContent.

Add this in the allprojects area of your android/buld.gradle file.

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.65+, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }

More detailed info about the problem and the fix here: https://github.com/facebook/react-native/issues/35210

Sign up to request clarification or add additional context in comments.

2 Comments

This broke on my face and I kept working with ios... I've never expected that things break so easily "without me touching anything". I've been looking for something like this for days, finally find it. Kudos my friend.
That is the only correct answer from among other. Thank you man!
23

change these two lines and its now working this was solution for react-native version .67 and lower from

 compileSdkVersion = 29
 targetSdkVersion = 29

to

 compileSdkVersion = 30
    targetSdkVersion = 30

for latest version here are the changes

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33 // with 31 was working fine
        targetSdkVersion = 31

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.2.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("de.undercouch:gradle-download-task:5.0.1")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

latest updated on react-native version .70 and above

compileSdkVersion = 33
targetSdkVersion = 33

7 Comments

I had to change from [ compileSdkVersion = 30 targetSdkVersion = 30 ] to [ compileSdkVersion = 31 targetSdkVersion = 31 ] to solve this issue
@JayantJoseph Setting compileSdk 31 without any other changes also works.
@JayantJoseph it brokes all my project.
@SalahAdDin maybe try it again, it worked for me (the 31 version).
I had to fixed it manually.
|
9

I fixed it by adding this code to the android/app/build.gradle

dependencies{
    ...other dependencies,

    implementation ("androidx.browser:browser:1.3.0"){
        force = true
    }
}

1 Comment

I am using react native 0.64.4 and this fix solved my issue
4

I found it after 4 hour of searching and testing several answers.

If you don't want to upgrade to SDK 31, add in android/app/build.gradle

android {
        ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

Taken form this GitHub answer.

3 Comments

this did not work and no explanation of why this has to be done.
This worked for me and is the best practice - changing other parts can be time consuming.
RN v 0.63.5 - this worked! Full 8 hours of attempted fixes until finally, one worked! Not sure wth is going on but, love it!
2

I was facing same issue too.

  1. There was an issue with the library of core-ktx and then I replaced it with this:

    implementation("androidx.core:core-ktx:1.6.0")
    
  2. Change your versions to 30 in app build.gradle:

    compileSdkVersion = 30
    targetSdkVersion = 30
    

My issue is resolved may be it helps in your case too.

Comments

2

I'm using RN 0.64.2 version and the react-native-firebase library transitively pulled in the newer version of androidx.browser:browser:1.4.0-alpha01 and androidx.appcompat:appcompat:1.4.0-alpha03.

in my app/build.gradle I forced the androidx.browser:browser and androidx.appcompat:appcompat versions to an earlier ones.

    runtimeOnly(group: 'androidx.browser', name: 'browser', version: '1.3.0') {
        force = true
    }
    runtimeOnly(group: 'androidx.appcompat', name: 'appcompat', version: '1.3.1') {
        force = true
    }

Comments

2

I have solved the issue by upgrading buildToolsVersion, compileSdkVersion and targetSdkVersion to 31 from 29

Comments

2

Just add this code block to the end of build.gradle file in app level

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

Comments

2

In our case: we re-created our react native app

We had a React Native app [email protected] with this config

minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29

We created a new app [email protected] and imported the code. the new config was

minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31

We faced the same problem (run android failed), so we changed compileSdkVersion from 31 into 33 and it worked, here is the new config

minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 31

Comments

1

from

buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29

to

buildToolsVersion = "30.0.0"
minSdkVersion = 16
compileSdkVersion = 30
targetSdkVersion = 30

react-native run-android

Comments

1

The error may also be here.

buildscript {
ext.kotlin_version = '1.6.10'
repositories {
    google()
    jcenter()
}

1 Comment

Could you explain what needs to be changed about this? Is this with the error, or is this the fixed version?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.