software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.81k stars 1.28k forks source link

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

Closed DigohD closed 1 year ago

DigohD commented 1 year ago

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

tjzel commented 1 year ago

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?

DigohD commented 1 year ago

Hi! Thanks for the quick answer.

Pardon me, I forgot mentioning that I am working on a windows 11 machine. My colleague who also uses a PC encounter the same error when testing the repo I linked.

Edit: I will try on my home PC as well later tonight

efstathiosntonas commented 1 year ago

can you try with ndk 24.0.8215888?

tjzel commented 1 year ago

@DigohD I'm no expert in these things but we have a CI that uses windows-latest GitHub virtual machine. Maybe take a look at its config, especially that NDK @efstathiosntonas mentioned and see if there are any key differences compared to your machine.

devnev commented 1 year ago

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.

DigohD commented 1 year ago

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.

Dat-Mobile commented 1 year ago

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

Electromorphous commented 9 months ago

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
Digital-Human-BK commented 9 months ago

Check your JDK versions, in my case, I had JDK 11.0.18, and a simple update to version 11.0.20 solved all the problems. Don't forget to run yarn start --reset-cache before you try to build.

Electromorphous commented 9 months ago

I do not have JDK, only JRE. And I don't see what's wrong with what I said. I also suggested to clean the cache and run again, and I said that's what worked for me so it's worth a try. Never said it will solve everyone's problems.

roots-ai commented 9 months ago

Any updates here?

tatiana-lonestone commented 9 months ago

I've got the same error after trying to update one lib using reanimated, but after remove any change (come back to a previous version on my git project), I can not remove this error

can you try with ndk 24.0.8215888?

<= This fix my project build after a 10 min gradlew clean. I don't understand why, but this works. Thank's :)

Ritikkk-09 commented 9 months ago

I've got the same error after trying to update one lib using reanimated, but after remove any change (come back to a previous version on my git project), I can not remove this error

can you try with ndk 24.0.8215888?

<= This fix my project build after a 10 min gradlew clean. I don't understand why, but this works. Thank's :)

And what is your react-native or reanimated or cmake version ?

GaboRocker1992 commented 8 months ago

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.

sen-ol commented 8 months ago

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.

moving the project to a folder with a shorter path solved my problem. Yes it is funny and absurd but also very frustrating. I wasted a lot time to solve this issue.

krendus commented 8 months ago

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

kyrieLiu3 commented 8 months ago

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.

@GaboRocker1992 Hi, guy, you're just my super rock star and save my day! It costs me the whole day to fix this one! Who's gonna believe the root cause is a project folder with a long name?

Tianjiao2000 commented 7 months ago

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.

This one is AMAAAAAZING!! Thanks a lot!

iamnynvk commented 4 months ago

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
iamnynvk commented 4 months ago

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.

GohilMahendra commented 4 months ago

try to install cmake with help of brew and update the rosseta. this thing worked for me

namycodes commented 4 months ago

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.

Haaaa, funny but true

matsura commented 3 months ago

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!

miallo commented 3 months ago

Thank you everyone for figuring this out! Indeed unsetting JAVA_TOOL_OPTIONS worked for us.

Question: does it make sense to reopen this issue, since AFAICT there is only a workaround, but the underlying issue seems to still exist :thinking:

gharivand commented 2 months ago

Most of the time you install react-native-reanimated for react-native-gesture-handler. My solution is to go to node_modules/react-native-gesture-handler/package.json and install the same version that is installed in this package. in my case, that was "^2.3.1".

otisidev commented 1 month ago

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.

This worked for me too. Thank you so much @GaboRocker1992 .

danilor commented 1 month ago

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. Not exactly related to native-reanimate, but same error on other library.

yasirgit62 commented 1 month ago

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

Asad-wego commented 1 month ago

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!

yasirgit62 commented 1 month ago

run react-native with sudo

On Fri, 26 Jul 2024 at 4:44 PM, Asad-wego @.***> wrote:

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!

— Reply to this email directly, view it on GitHub https://github.com/software-mansion/react-native-reanimated/issues/4712#issuecomment-2252587132, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH27UKHH4NG2FSAJ4YHMFITZOIZC5AVCNFSM6AAAAAA2GDY2G6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJSGU4DOMJTGI . You are receiving this because you commented.Message ID: @.*** com>

eskalVAR commented 1 month ago

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

anshu9165 commented 4 weeks ago

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

FAILURE: Build failed with an exception.

same issue i am facing please help to resolve

jawadkhan27 commented 4 weeks ago

same error.

Task :react-native-reanimated:configureCMakeDebug[arm64-v8a] FAILED 65 actionable tasks: 10 executed, 55 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times. Note: C:\AwesomeProject\node_modules\react-native-gesture-handler\android\paper\src\main\java\com\swmansion\gesturehandler\NativeRNGestureHandlerModuleSpec.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.

dinesh-brilworks commented 3 weeks ago

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

GSSPawanKumarSingh commented 2 weeks ago

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

GSSPawanKumarSingh commented 2 weeks ago

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!

Have you get any solution?

GSSPawanKumarSingh commented 2 weeks ago

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!

cucereanum commented 2 weeks ago

If you want to have the "new architecture" and "bridgeless" mode enabled, I resolved this by updating to "react-native:0.75.1" and "react-native-reanimated:3.15.0"

I used this as a reference: https://github.com/software-mansion/react-native-reanimated/tree/main/apps/fabric-example