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.
- Get more help at https://help.gradle.org`
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)
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 theseNo such file or directory
errors.Yes same with me, and also
react-native-safe-area-context
andreact-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.
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 afternpx react-native init rn682 --version=0.68.2
. However on my upgraded app nowRnScreens
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
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 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