androidreact-nativecmakeninja

CMake Build Error with react-native-reanimated: 'mkdir: No such file or directory' (Path Length Issue)


I am trying to build my React Native application for Android, but I'm running into an issue when building react-native-reanimated with CMake. The error I get is :

Task :react-native-reanimated:buildCMakeRelWithDebInfo[armeabi-v7a] FAILED C/C++: ninja: error: mkdir(src/main/cpp/reanimated/CMakeFiles/reanimated.dir/C_/Users/ricar/Documents/Github/StockItUp/node_modules/react-native-reanimated/Common): No such file or directory

I suspect this is related to a path length limitation on Windows, as the error indicates that it can't create a directory due to the path being too long.

Here's what I've tried so far :

  1. Moved the project to the root of my drive (C:\StockItUp) to shorten the path.

  2. Modified my babel.config.js with :

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

But this didn't resolve the issue.

I also tried cleaning the build with : ./gradlew clean

And rebuilding with : ./gradlew assembleRelease

But the problem persists.

Environment : React Native Version: 0.75.4
react-native-reanimated Version: 3.16.0
Operating System: Windows 11

Has anyone encountered this issue before and found a solution? Is there a way to force CMake or Ninja to work with these long paths, or is there another workaround for building react-native-reanimated on Windows ?

Any help would be greatly appreciated !


Solution

  • The version of reanimated you are using, the maintainer didn't enable the new arch feature on it which is causing this. Try downgrading your react-native-reanimated