react-native-reanimated: Task :react-native-reanimated:configureCMakeDebug[arm64-v8a] FAILED for Android In empty project

Description

We recently upgraded to latest React-Native (0.72.2) and upgraded Reanimated to 3.3.0. After this upgrade, we get the following error when running assembleDebug for Android:

Task :react-native-reanimated:configureCMakeDebug[arm64-v8a] FAILED

FAILURE: Build failed with an exception.

* What went wrong:                                                                      
Execution failed for task ':react-native-reanimated:configureCMakeDebug[arm64-v8a]'.    
> Picked up _JAVA_OPTIONS: -Xmx2048M

After failing to find a solution to the issue I created a brand new react native project with react-native-reanimated and tried building it for Android:

npx react-native init ReactNativeTest
cd ReactNativeTest
npm i react-native-reanimated
cd android
gradlew clean
gradlew assembleDebug

Also added to babel config.:

 plugins: [
    [
      'react-native-reanimated/plugin',
      {
        relativeSourceLocation: true,
      },
    ],
  ],

The same error occurs in the brand new project.

npx react-native run-android fails with the same error as assembleDebug.

Reanimated builds and runs as expected on iOS devices using Xcode.

Steps to reproduce

  1. Init a new react native project
  2. install reanimated using npm
  3. clean and build for android

Snack or a link to a repository

https://github.com/DigohD/Reanimated-build-error-cmake-config-issue-repo

Reanimated version

3.3.0

React Native version

0.72.2

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

None

Device model

No response

Acknowledgements

Yes

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 14
  • Comments: 59 (2 by maintainers)

Most upvoted comments

It’s funny and absurd, but the issue is due to the project path being too long. I recommend copying or moving your project to c:\ or desktop. Delete the node_modules folder, run npm i, cd android & ./gradlew clean, and then build.

Resolved by following steps

  1. Remove build and .cxx folder in the android/app/ directory.
  2. Run the command in terminal : - cd android && ./gradlew clean
  3. Open gradle.properties files
  4. newArchEnabled=false
  5. Run the project : - cd … && npm start – --reset-cache - npm run android

This worked for me (Windows 10 | react-native 0.72.5 | react-native-reanimated 3.5.4)

cd android
./gradlew clean
cd ..
npm start -- --reset-cache

can you try with ndk 24.0.8215888?

Encountered a similar issue here: https://github.com/react-native-community/react-native-circleci-orb/issues/171 With some (ndk? sdk?) versions, the Picked up _JAVA_OPTIONS output causes a failure. Removing _JAVA_OPTIONS from the environment will fix it.

Execution failed for task ‘:react-native-reanimated:buildCMakeRelWithDebInfo[armeabi-v7a]’. getting same issue today Any Luck?

Get resolved after doing the below steps

  1. Deleted node_module
  2. gradlew clean
  3. delete build folder if any in android
  4. Close VS Code
  5. Install node_module
  6. Separately installed npm i react-native-reanimated@3.6.1
  7. Build the project again.

Work like a charm!!! Happy Coding!

If you have the same problem after all maybe you can try delete the “^” of the number version (if you have that symbol) and repeat the ./gradlew clean and --reset-cache

Enable Bridgeless Mode

Bridgeless Mode

1. Enable Bridgeless flag in native

Android In your MainApplication.kt file, update the onCreate function by passing the bridglessEnabled = true flag to the load invocation.

// MyMainApplication.kt

import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load

override fun onCreate() {
  ...
  if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
    // Set bridgelessEnabled to true here to enable Bridgeless, it's false by default
-   load()
+   load(bridgelessEnabled = true)
  }
  ...
}

iOS

To enable Bridgeless for your React Native app, you need to override function bridgelessEnabled in app’s AppDelegate.mm:

// AppDelegate.mm

- (BOOL)bridgelessEnabled
{
    return YES;
}

2. Enable New Architectures

Open gradle.properties file newArchEnabled=true

FINALLY, Complete the configuration for Enable Bridgeless Mode.

I encountered an error while updating my React Native project from version 0.72.x to 0.74.3. The project configuration includes:

React Native: 0.74.3 React Native Reanimated: ^3.14.0 Gradle: Updated from 7.5 to 8.7 Build Tool: Fastlane CI Environment: CircleCI Docker Image: cimg/android:2023.08.1-node Problem The project works fine on my local machine in development mode, and I can generate builds using Fastlane on my machine without any issues. However, when running the build job on CircleCI using bundle exec fastlane staging I encounter the following error:

> Task :react-native-reanimated:configureCMakeRelWithDebInfo[arm64-v8a] FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-reanimated:configureCMakeRelWithDebInfo[arm64-v8a]'.
> [CXX1416] Could not find Ninja on PATH or in SDK CMake bin folders.

Has anyone encountered a similar issue or found a solution for this? Any steps or suggestions to fix this would be greatly appreciated. Thank you!

Encountered a similar issue here: https://github.com/react-native-community/react-native-circleci-orb/issues/171 With some (ndk? sdk?) versions, the Picked up _JAVA_OPTIONS output causes a failure. Removing _JAVA_OPTIONS from the environment will fix it.

Remove _JAVA_OPTIONS in cimg/android on circleci and it works now Thank you

I am having the same issue with some other library,

Execution failed for task ‘:react-native-fast-openpgp:configureCMakeDebug[arm64-v8a]’.

[CXX1410] …/node_modules/react-native-fast-openpgp/android/.cxx/Debug/5v282i3v/arm64-v8a/android_gradle_build.json debug|arm64-v8a : expected buildTargetsCommandComponents command ‘ninja’ to exist

Can confirm unsetting _JAVA_OPTIONS fixes build issue. Surprising this is still an issue!

installing the latest version of react-native-reanimated npm i react-native-reanimated@latest and then clearing the metro cache npm start -- --reset-cache fixed it for me

I reset my PC and reinstalled everything and now it works. I tried re-adding the _JAVA_OPTIONS variable just to check if that could be the issue I had before, and it indeed causes the error to come back.

I did not try ndk 24.0.8215888, but tried ndk 25 yesterday which did not solve the issue.

Thank you all for helping me out.

Hi @DigohD. I couldn’t reproduce the error you mentioned - my android build works just fine on cloning the repo you provided.

Although looking at this:

Task :react-native-reanimated:configureCMakeDebug[arm64-v8a] FAILED

FAILURE: Build failed with an exception.

* What went wrong:                                                                      
Execution failed for task ':react-native-reanimated:configureCMakeDebug[arm64-v8a]'.    
> Picked up _JAVA_OPTIONS: -Xmx2048M

I think this might be architecture related. Do you have Rosetta installed on your machine?

Execution failed for task ‘:react-native-reanimated:buildCMakeRelWithDebInfo[armeabi-v7a]’. getting same issue today Any Luck?

Get resolved after doing the below steps

1. Deleted node_module

2. gradlew clean

3. delete build folder if any in android

4. Close VS Code

5. Install node_module

6. Separately installed npm i react-native-reanimated@3.6.1

7. Build the project again.

Work like a charm!!! Happy Coding!

Thank you, this is the only solution that worked for me ❤

@ronix99 thanks. after trying for hours, found and tried your solution and it worked, removed “^” from reanimated.

My error went away after downloading and using previous version of NDK:

android/build.gradle:

buildscript { ext { buildToolsVersion = “34.0.0” minSdkVersion = 23 compileSdkVersion = 34 targetSdkVersion = 34 ndkVersion = “26.1.10909125” # error went away after downloading this from Android Studio // ndkVersion = “27.0.12077973” # this is the most recent version causing the breaking changes kotlinVersion = “1.9.24” } repositories { google() mavenCentral() } dependencies { classpath(“com.android.tools.build:gradle”) classpath(“com.facebook.react:react-native-gradle-plugin”) classpath(“org.jetbrains.kotlin:kotlin-gradle-plugin”) } }

apply plugin: “com.facebook.react.rootproject”

installing the latest version of react-native-reanimated npm i react-native-reanimated@latest and then clearing the metro cache npm start -- --reset-cache fixed it for me

PROBLEM WAS IN THE NDK VERSION I WAS USING LATEST 27 BUT NOW USED 25

What worked for me is running cd android and ./gradleW assembleDebug --stacktrace. This gave me the error stack trace which showed an IllegalStateException the cause of which was the JAVA_TOOL_OPTIONS env variable. So I unset it. After that an issue appeared about CMakeLists - this was caused by having env var _JAVA_OPTIONS set. Unset this well and it builds successfully!