react-native-reanimated: Task :react-native-reanimated:buildCMakeRelWithDebInfo[arm64-v8a] FAILED during assembleRelease

Description

With assembleDebug the build ends successfully with no issue, I am also able to run my app both web and android for debugging with no issue.

When I try to assembleRelease I am getting the following error:


> Task :react-native-reanimated:configureCMakeRelWithDebInfo[arm64-v8a]                                                                                                                                                       
C/C++: CMake Warning in src/main/cpp/reanimated/CMakeLists.txt:
C/C++:   The object file directory
C/C++:     C:/Users/***/node_modules/react-native-reanimated/android/.cxx/RelWithDebInfo/161d1w1k/arm64-v8a/src/main/cpp/reanimated/CMakeFiles/reanimated.dir/./
C/C++:   has 180 characters.  The maximum full path to an object file is 250
C/C++:   characters (see CMAKE_OBJECT_PATH_MAX).  Object file
C/C++:     C_/Users/***/node_modules/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/ReanimatedWorkletRuntimeDecorator.cpp.o
C/C++:   cannot be safely placed under this directory.  The build may not work
C/C++:   correctly.

> Task :react-native-reanimated:buildCMakeRelWithDebInfo[arm64-v8a] FAILED
C/C++: ninja: error: mkdir(src/main/cpp/reanimated/CMakeFiles/reanimated.dir/C_/Users/***/node_modules/react-native-reanimated/Common): No such file or directory

FAILURE: Build failed with an exception.                                                                                                                                                                                      

* What went wrong:
Execution failed for task ':react-native-reanimated:buildCMakeRelWithDebInfo[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `C:\Users\****\node_modules\react-native-reanimated\android\.cxx\RelWithDebInfo\161d1w1k\arm64-v8a'
  [0/2] Re-checking globbed directories...
  ninja: build stopped: .

  C++ build system [build] failed while executing:
      @echo off
      "C:\\Users\\****\Sdk\\cmake\\3.22.1\\bin\\ninja.exe" ^
        -C ^
        "C:\\Users\\****\\node_modules\\react-native-reanimated\\android\\.cxx\\RelWithDebInfo\\161d1w1k\\arm64-v8a" ^
        reanimated ^
        worklets
    from C:\Users\****\node_modules\react-native-reanimated\android
  ninja: error: mkdir(src/main/cpp/reanimated/CMakeFiles/reanimated.dir/C_/Users/***/node_modules/react-native-reanimated/Common): No such file or directory

* 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.

I tried different solution that I saw around the issues here, including updating my NDK, reinstalling node_modules and updating the babel.config with the correct plugins.

Steps to reproduce

  1. over windows machine
  2. cd android
  3. ./gradlew assembleRelease

Snack or a link to a repository

dont have

Reanimated version

3.16.1

React Native version

0.75.2

Platforms

Android

JavaScript runtime

None

Workflow

Expo Go

Architecture

Fabric (New Architecture)

Build type

Release app & dev bundle

Device

Android emulator

Device model

No response

Acknowledgements

Yes

About this issue

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

Most upvoted comments

I moved the project to a different location so it will have a shorter path and the build went successfully. :S

I am having the same issue and have the project at only four directories under C: (C:\Projects\Dir1\Dir2\Dir3\node_modules). I think this issue should be re-opened as this does not seem reasonable.

Hi there, I’m having the same issue here. I’ve tried the following versions:

  • RN 0.74.6 + reanimated ~3.15.x (Builds debug mode but don’t build on release mode);
  • RN 0.74.6 + reanimated ~3.16.x (fails on both release and debug);
  • RN 0.75.4 + reanimated ~3.15.x (Builds debug mode but don’t build on release mode);
  • RN 0.75.4 + reanimated ~3.16.x (fails on both release and debug);

Using Cmake 3.31.5 fixed it for me

I was able to fix this problem by enabling long path support in Windows, installing cmake 3.31.0 via Android Studio, and creating a global environment variable CMAKE_VERSION set to 3.31.0.

Props to https://github.com/software-mansion/react-native-reanimated/issues/6771#issuecomment-2514612565

Hi all, we added “Building for Android on Windows” troubleshooting guide to Reanimated docs. Please consult this page if you face any build errors for Android devices when building your app on Windows.

➡️ https://docs.swmansion.com/react-native-reanimated/docs/guides/building-on-windows

If the problem still persists, feel free to re-open the issue or submit a new one.