react-native: Windows: Error: unable to open output file when enabling the new architecture

Description

I’ve installed the new version 0.68 then enable the new architecture and try to run npx react-native run-android and it doesn’t build. I believe that it is because the path has front and backlashes.

`BUILD FAILED in 3m 21s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 Note: D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native-gradle-plugin\src\main\java\com\facebook\react\codegen\generator\SchemaJsonParser.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:ReactAndroid:buildNdkBuildDebug’.

Build command failed. Error while executing process C:\Users\user\AppData\Local\Android\Sdk\ndk\21.4.7075529\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\src\main\jni\react\jni\Android.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj NDK_LIBS_OUT=D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/lib NDK_APPLICATION_MK=D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid/src/main/jni/Application.mk THIRD_PARTY_NDK_DIR=D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\third-party-ndk REACT_COMMON_DIR=D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid/…/ReactCommon REACT_GENERATED_SRC_DIR=D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build/generated/source REACT_SRC_DIR=D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid/src/main/java/com/facebook/react -j16 butter fabricjni fb folly_futures folly_json glog glog_init hermes-executor-debug hermes-executor-release jscexecutor jsi jsijniprofiler jsinspector logger mapbufferjni react_codegen_rncore react_config react_debug react_nativemodule_core react_render_animations react_render_attributedstring react_render_componentregistry react_render_core react_render_debug react_render_graphics react_render_imagemanager react_render_leakchecker react_render_mapbuffer react_render_mounting react_render_runtimescheduler react_render_scheduler react_render_telemetry react_render_templateprocessor react_render_textlayoutmanager react_render_uimanager react_utils reactnativeblob reactnativejni reactnativeutilsjni reactperfloggerjni rrc_image rrc_root rrc_text rrc_unimplementedview rrc_view runtimeexecutor turbomodulejsijni yoga} [armeabi-v7a] Prebuilt : libc++_shared.so <= <NDK>/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/ [armeabi-v7a] Prebuilt : libfbjni.so <= D:/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/jni/first-party/fbjni/jni/armeabi-v7a/ [armeabi-v7a] Compile++ thumb: folly_json <= Assume.cpp [armeabi-v7a] StaticLibrary : libcallinvoker.a [armeabi-v7a] Compile++ thumb: folly_json <= ToAscii.cpp [armeabi-v7a] SharedLibrary : libruntimeexecutor.so [armeabi-v7a] Prebuilt : libhermes.so <= D:/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/build/third-party-ndk/hermes/jni/armeabi-v7a/ make: Nothing to be done for ‘runtimeexecutor’. [armeabi-v7a] Compile++ thumb: folly_json <= ScopeGuard.cpp [armeabi-v7a] Prebuilt : libjsc.so <= D:/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/build/third-party-ndk/jsc/jni/armeabi-v7a/ [armeabi-v7a] Compile++ thumb: fabricjni <= OnLoad.cpp [armeabi-v7a] Compile++ thumb: fabricjni <= AsyncEventBeatV2.cpp [armeabi-v7a] Compile++ thumb: fabricjni <= ReactNativeConfigHolder.cpp [armeabi-v7a] Compile++ thumb: fabricjni <= Binding.cpp [armeabi-v7a] Compile++ thumb: fabricjni <= FabricMountingManager.cpp [armeabi-v7a] Compile++ thumb: fabricjni <= SurfaceHandlerBinding.cpp [armeabi-v7a] Compile++ thumb: fabricjni <= ComponentFactory.cpp [armeabi-v7a] Compile++ thumb: fabricjni <= JBackgroundExecutor.cpp [armeabi-v7a] Compile++ thumb: folly_json <= json_pointer.cpp [armeabi-v7a] Compile++ thumb: glog <= signalhandler.cc [armeabi-v7a] Compile++ thumb: glog <= symbolize.cc [armeabi-v7a] Compile++ thumb: glog <= raw_logging.cc [armeabi-v7a] Compile++ thumb: glog <= vlog_is_on.cc [armeabi-v7a] Compile++ thumb: glog <= utilities.cc [armeabi-v7a] Compile++ thumb: glog <= demangle.cc [armeabi-v7a] Compile++ thumb: glog <= logging.cc

error: unable to open output file ‘D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/OnLoad.o’: ‘No such file or directory’ 1 error generated. make: *** [C:/Users/user/AppData/Local/Android/Sdk/ndk/21.4.7075529/build//…/build/core/build-binary.mk:478: D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/OnLoad.o] Error 1 make: *** Waiting for unfinished jobs… error: unable to open output file ‘D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/AsyncEventBeatV2.o’: ‘No such file or directory’ 1 error generated. make: *** [C:/Users/user/AppData/Local/Android/Sdk/ndk/21.4.7075529/build//…/build/core/build-binary.mk:478: D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/AsyncEventBeatV2.o] Error 1 error: unable to open output file ‘D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/ReactNativeConfigHolder.o’: ‘No such file or directory’ 1 error generated. make: *** [C:/Users/user/AppData/Local/Android/Sdk/ndk/21.4.7075529/build//…/build/core/build-binary.mk:478: D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/ReactNativeConfigHolder.o] Error 1 error: unable to open output file ‘D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.o’: ‘No such file or directory’ 1 error generated. make: *** [C:/Users/user/AppData/Local/Android/Sdk/ndk/21.4.7075529/build//…/build/core/build-binary.mk:478: D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.o] Error 1 error: unable to open output file ‘D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/FabricMountingManager.o’: ‘No such file or directory’ 1 error generated. make: *** [C:/Users/user/AppData/Local/Android/Sdk/ndk/21.4.7075529/build//…/build/core/build-binary.mk:478: D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/FabricMountingManager.o] Error 1 error: unable to open output file ‘D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/SurfaceHandlerBinding.o’: ‘No such file or directory’ 1 error generated. make: *** [C:/Users/user/AppData/Local/Android/Sdk/ndk/21.4.7075529/build//…/build/core/build-binary.mk:478: D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/SurfaceHandlerBinding.o] Error 1 error: unable to open output file ‘D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/ComponentFactory.o’: ‘No such file or directory’ 1 error generated. make: *** [C:/Users/user/AppData/Local/Android/Sdk/ndk/21.4.7075529/build//…/build/core/build-binary.mk:478: D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/ComponentFactory.o] Error 1 error: unable to open output file ‘D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/JBackgroundExecutor.o’: ‘No such file or directory’ 1 error generated. make: *** [C:/Users/user/AppData/Local/Android/Sdk/ndk/21.4.7075529/build//…/build/core/build-binary.mk:478: D:\PERSONAL\PROGRAMMING\REACTNATIVE\TestnewArc\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\363s2q4f/obj/local/armeabi-v7a/objs-debug/fabricjni/D_/PERSONAL/PROGRAMMING/REACTNATIVE/TestnewArc/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/JBackgroundExecutor.o] Error 1

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

Version

0.68

Output of npx react-native info

System: OS: Windows 10 10.0.22000 CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics Memory: 212.03 MB / 6.68 GB Binaries: Node: 14.17.3 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD npm: 7.19.1 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels: 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.1.0, 33.0.0, 33.0.0 System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom Android NDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Version 2021.1.0.0 AI-211.7628.21.2111.8193401 Visual Studio: Not Found Languages: Java: 17.0.2 - C:\Program Files\Common Files\Oracle\Java\javapath\javac.EXE npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.68.0 => 0.68.0 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

  • In windows machine install fresh version of RN
  • Enable new architecture in gradle.properties. newArchEnabled=true
  • run npx react-native run-android

Snack, code example, screenshot, or link to a repository

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 44 (12 by maintainers)

Most upvoted comments

hey folks - just to give you a quick update, I’ve reported this internally at Microsoft and a couple of engineers have been looking into it. We think we have found the commit that “broke” this and we are looking into ways of fixing this, by end of the week we should have some options on the table - the aim is for this to be fixed in 0.68.1

The same happens for me too. The same app builds on a Mac (for android ofc) without problems, but on Windows the buildNdkBuildDebug task fails with these No such file or directory errors.

Yes same with me, and also react-native-safe-area-context and react-native-gesture-handler. So currently I think, it’s still not possible to build any medium to large apps with the new architecture, as these libs are really essential.

Hi @cortinico @kelset … I’ve a draft PR, not a generic fix, but may unblock people if the root project is short … https://github.com/facebook/react-native/pull/33582/files

Somehow NDK AR can’t handle long paths even after enabling long paths in Windows! We will continue looking for better fix. And more importantly, we should have a fix for the CMake command in main branch. I think NDK_APP_SHORT_COMMANDS is not available in CMake scripts.

@mganandraj @cortinico what do you think?

It depends on the amount of C++ code the library is exposing.

If the external library is just using the Codegen + exposing JS/Android/iOS code, they’ll get the patch for free.

If the library is exposing an Android.mk file, they would have to patch it as well. I guess the issue should be raised against the library, as it’s their responsibility to make sure the library builds on the platform they decide to support.

As a side note: we’re moving to having CMake files instead of Android.mk files which should mitigate this and other similar build issues.

For me 0.68.2 solved the problems, a fresh app builds and runs after npx react-native init rn682 --version=0.68.2. However on my upgraded app now RnScreens fails for the same reason. So it seems lib authors should also make some fixes.

Just a heads up: we’re working a 0.68.2 which will (hopefully) fix the build failures on Windows

@mganandraj I can try to generate directly in C:/

@kelset I did exactly the steps I asked. I think this might help you to see the problem https://gradle.com/s/lpfx26hngftm6

According to @mganandraj It seems like that a bump to NDK 23 would fix this issue. If so, that’s the patch:

I’m looking for someone with a windows machine that is willing to test this

No, it didn’t work as expected on my computer. Same error like before.

According to @mganandraj It seems like that a bump to NDK 23 would fix this issue. If so, that’s the patch:

I’m looking for someone with a windows machine that is willing to test this

@mrtaiw You can try Linux, there is no problem on Archlinux, Ubuntu. I didn’t test other distributions

The LongPathsEnabled setting in the regedit was 0 for me, so I switched it to 1 and rebooted. Now the the bin/ld binary from the NDK throws the same error for the following file:

C:\Users\Dell\react-native\my-app\node_modules\react-native\ReactAndroid\build\intermediates\cxx\Debug\65142t73/obj/local/armeabi-v7a/objs-debug/logger/C_/Users/Dell/react-native/my-app/node_modules/react-native/ReactAndroid/__/ReactCommon/logger/react_native_log.o

The file exists, I can ls it in powershell, so maybe the ld binary doesn’t handle longPaths 🤔 There was an issue which is maybe related (not sure which versions they were talking about).

I tried to switch the ndkVersion, but for me the next version is 22.1.7171670 which throws Bad file descriptor errors, so I assume its not supported anyways. I had to put it in node_modules\react-native\ReactAndroid\build.gradle, because the project’s ndkVersion setting is totally ignored, but that’s a different issue.

Edit: Well after some tries, now /toolchains/llvm/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ar throws the error from the NDK for ontop_arm_aapcs_elf_gas.o which exists too. Then I build again, and the above mentioned ld error comes again.

The same. ReactAndroid does not support compiling on windows for a long time. The old architecture has bean packed into AAR, so it works well, but the new one needs you to compile native libs and it seems that something problem on windows