2

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"

Ravis Farooq
  • 168
  • 10
  • Are there features from the new version you 100% need? You may be aware, the `rc` means release *candidate*, it's not an official release. Rolling back is probably your best option. – Abe Nov 09 '22 at 05:43
  • I didn't alter anything in my code it was working fine but now it is not working my previous compileSdkVersion was 30 and targetSdkVersion 30 i only changed it to 31 as it was throwing error – Ravis Farooq Nov 09 '22 at 05:49
  • check https://twitter.com/reactnative/status/1589296764678705155 also – Abe Nov 09 '22 at 15:58

3 Answers3

4

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

Thanhal P A
  • 4,097
  • 3
  • 18
  • 38
0

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

Vin Xi
  • 986
  • 2
  • 11
  • I have jdk8 installed and if i update it, it is showing me ERROR: requires JDK11 or higher. Incompatible major version detected: '8' – Ravis Farooq Nov 09 '22 at 06:59
0

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

A. kanojia
  • 431
  • 1
  • 4
  • 8