skip to Main Content

I have tried many solutions but all in vain, including this
React Native Android build failure with different errors without any changes in code for past days due to publish of React Native version 0.71.0-rc.0
I am having deadline ahead and my project is not building from last 4 days, any help will be appreciated.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> 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.activity:activity-compose:1.4.0.
     AAR metadata file: /Users/dev/.gradle/caches/transforms-2/files-2.1/c35837abe789834d04f87678613d3ab9/jetified-activity-compose-1.4.0/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 have tried compileSdkVersion = 31
targetSdkVersion = 31
after that I am getting

Execution failed for task ':react-native-incall-manager:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

My build.gradle file is

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        androidXCore = "1.7.0" 
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.1")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}

React native version is "^0.66.3"

3

Answers


  1. This is an issue from gradle servers. There are many official fixes being launched. You can either upgrade react-native to 0.70.5 or you can patch it using fix available here. https://github.com/facebook/react-native/issues/35249

    Login or Signup to reply.
  2. Your app was working fine before right so, please follow below steps and check

    1. Revert back all the changes you have made after that (if you changed versions of sdk, gradle, java, react-native etc)
    2. Delete node_modules
    3. Delete build folders (android/build & android/app/build)
    4. Recheck the package.json if the react-native version is as which was worked before (in your case 0.66.3)
    5. Run npm install or yarn to install packages
    6. Clean (remove gradle cache like mentioned here : https://stackoverflow.com/a/30450020/10657559) and rebuild the app by adding the below changes to your android/build.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())
    
    
    buildscript {
         // ...
    }
        
        
    allprojects {
        configurations.all {
              resolutionStrategy {
                force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
              }
        }
        // ...  
    }

    Ref: Fix and updates on Android build failures happening since Nov 4th 2022 #35210

    Login or Signup to reply.
  3. It is causing due to some issue at react-native since friday, 4 Nov 2022.
    Updating your react-native version can solve it.

    Note: No need to update gradle files for this issue.

    All fix version of RN are mentioned here.
    Ex: if you are on 0.64.3, change to 0.64.4

    ref: https://github.com/facebook/react-native/issues/35210

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search