react-native-safe-area-context icon indicating copy to clipboard operation
react-native-safe-area-context copied to clipboard

Build failed on RN version 0.69.1

Open Willham12 opened this issue 3 years ago • 12 comments

node_modules/react-native-codegen/lib/parsers/typescript/index.js:191
        throw parsingErrors[0];
        ^

UnusedModuleTypeScriptInterfaceParserError: Module NativeSafeAreaContext.d: Unused NativeModule spec. Please load the NativeModule by calling TurboModuleRegistry.get<Spec>('<moduleName>').

Willham12 avatar Jul 04 '22 12:07 Willham12

+1

ZentPeople avatar Jul 04 '22 15:07 ZentPeople

+1

antoncojocaru avatar Jul 05 '22 23:07 antoncojocaru

I'm having the same problem. Anyone found a solution for this?

Skullcan avatar Jul 13 '22 16:07 Skullcan

Did you create a new project with version 0.69.1 or update an existing project with an older react-native version?

antoncojocaru avatar Jul 14 '22 21:07 antoncojocaru

It's an updated version. Looks good with a diff.

Willham12 avatar Jul 15 '22 06:07 Willham12

Did you create a new project with version 0.69.1 or update an existing project with an older react-native version?

I'm using a fresh npx react-native init project.

Steps to reproduce:

  • create new project using npx react-native init
  • change to the new architecture, make sure its building correctly
  • add react-native-safe-area-context and try to rebuild with npx react-native android.
E:\projetos\reactnice\node_modules\react-native-codegen\lib\parsers\typescript\index.js:191
        throw parsingErrors[0];
        ^

UnusedModuleTypeScriptInterfaceParserError: Module NativeSafeAreaContext.d: Unused NativeModule spec. Please load the NativeModule by calling TurboModuleRegistry.get<Spec>('<moduleName>').

I suspect this is related to the react-native-code-gen Gonna try to build it w/o the lib in the project after lunch and report back.

Skullcan avatar Jul 15 '22 15:07 Skullcan

If you start a new project with 0.69 you don't need to do thats changes in your project. To enable new architecture on android you can, set the newArchEnabled property to true by either:

  • Changing the corresponding line inside the android/gradle.properties file.
  • Set an environment variable ORG_GRADLE_PROJECT_newArchEnabled=true
  • Invoke Gradle with -PnewArchEnabled=true

And nothing more.

If you, like us :), make changes from Prerequisites for Applications from official documentation for new 0.69 project, or you upgrade to 0.69 from previous versions (with new acrhitecture enabled) you need to remove from /android/app/build.gradle this lines:

apply plugin: "com.facebook.react"

react { reactRoot = rootProject.file("../node_modules/react-native/") codegenDir = rootProject.file("../node_modules/react-native-codegen/") }

And this: implementation project(":ReactAndroid")

replace with:

implementation "com.facebook.react:react-native:+"

antoncojocaru avatar Jul 15 '22 16:07 antoncojocaru

Ok, thanks for the information!

So I tried to build it again using the suggested changes. After I cloned the project again from https://github.com/Skullcan/reactnice. Ran a build w/o problems in the emulator. Added react-native-safe-area-context again and tried to run again.

The error thrown was:

Execution failed for task ':react-native-safe-area-context:configureNdkBuildDebug[arm64-v8a]'. [CXX1405] error when building with ndkBuild using E:\projetos\reactnice\node_modules\react-native-safe-area-context\android\src\main\jni\Android.mk: Build command failed. Android NDK: ERROR:E:\projetos\reactnice\node_modules\react-native-safe-area-context\android\src\main\jni\Android.mk:fb: LOCAL_SRC_FILES points to a missing file Android NDK: Check that E:\projetos\reactnice\android\app\build/react-ndk/exported/arm64-v8a/libfb.so exists or that its path is correct

PS: The file mentioned in the error exists. image

Some context:

  • I'm running this build in a Windows 11 machine.
  • I had to change the NDK version to 23.1.7779620 because of the maximum object file path in windows is 250 characters and the build was failing using the standard version 21.4.7075529.
  • The project builds fine if I remove react-native-safe-area-context.

This is my npx react-native info fwiw:

E:\projetos\reactnice>npx react-native info info Fetching system and libraries information... System: OS: Windows 10 10.0.22622 CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz Memory: 12.83 GB / 31.87 GB Binaries: Node: 16.15.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD npm: 8.5.2 - ~\AppData\Roaming\npm\npm.CMD Watchman: 20200914.225852.0 - C:\Users\skull\AppData\Local\watchman\watchman.EXE SDKs: Android SDK: API Levels: 23, 25, 27, 28, 29, 30, 31, 33 Build Tools: 28.0.3, 29.0.1, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 33.0.0, 33.0.0 System Images: android-24 | Google Play Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-31 | Google Play Intel x86 Atom_64, android-33 | Google Play Intel x86 Atom_64 Android NDK: 22.1.7171670 Windows SDK: AllowDevelopmentWithoutDevLicense: Enabled AllowAllTrustedApps: Enabled Versions: 10.0.19041.0 IDEs: Android Studio: Not Found Visual Studio: Not Found Languages: Java: 11.0.15 - E:\jdk\azul-11.0.15\bin\javac.EXE npmPackages: @react-native-community/cli: Not Found react: 18.0.0 => 18.0.0 react-native: 0.69.1 => 0.69.1 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

Thanks in advance for the help!

Skullcan avatar Jul 15 '22 18:07 Skullcan

I think you should try to install react-native-codegen (0.69.1 version) And after, run ./gradlew clean (inside android project folder)

antoncojocaru avatar Jul 15 '22 19:07 antoncojocaru

I think you should try to install react-native-codegen (0.69.1 version) And after, run ./gradlew clean (inside android project folder)

Hi, I tried using the react-native-codegen 0.69.1 version, same error. Tried some fixes I saw in the react-native-gesture-handler lib in this PR too. Sadly no success building it.

I also tried to build it under a WSL2 instance I have running here. Got pretty much the same error in all attempts.

Android NDK: ERROR:/home/skull/projetos/reactnice/node_modules/react-native-safe-area-context/android/src/main/jni/Android.mk:fb: LOCAL_SRC_FILES points to a missing file Android NDK: Check that /home/skull/projetos/reactnice/android/app/build/react-ndk/exported/arm64-v8a/libfb.so exists or that its path is correct

I'm at a loss atm. Dunno what I'm doing wrong hahaha

Skullcan avatar Jul 18 '22 13:07 Skullcan

does anyone solved it?? am getting the same

SudarshJain avatar Jul 28 '22 04:07 SudarshJain

Any updates on this issue? Anyone fixed it?

mechaadi avatar Aug 11 '22 11:08 mechaadi

does anyone solved it?? am getting the same

Any updates on this issue? Anyone fixed it?

Hey, the solution from https://github.com/th3rdwave/react-native-safe-area-context/issues/294#issuecomment-1185682181 works for me! 🥳

In my case I needed to remove the following lines in android/app/build.gradle:

-apply plugin: "com.facebook.react"
-react {
-    reactRoot = rootProject.file("../node_modules/react-native/")
-    codegenDir = rootProject.file("../node_modules/react-native-codegen/")
-    jsRootDir = rootProject.file("../")
-    libraryName = "appname"
-    codegenJavaPackageName = "com.appname"
-}

When it comes to the libfb.so error, one solution is to simply build the app again. Usually it works on the second attempt. If you CI fails, you can add a step to run the task cd android && ./gradlew :ReactAndroid:packageReactNdkDebugLibs that will compile libfb.so. Then the app should build as normal.

tomekzaw avatar Aug 22 '22 10:08 tomekzaw

anyone found a solution for this still getting the same error

[CXX1405] error when building with ndkBuild using node_modules/react-native-safe-area-context/android/src/main/jni/Android.mk: Build command failed.

omars94 avatar Sep 21 '22 21:09 omars94

Compiled and released an app with RN 0.70.1.

Willham12 avatar Sep 22 '22 07:09 Willham12