Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not building in Android for React Native 76.0 new arch enabled project but works for iOS #86

Open
Gautham495 opened this issue Oct 28, 2024 · 8 comments

Comments

@Gautham495
Copy link

Current behavior
Does not build in android and ios for new arch.

Works well in old arch

Android Error:

Expected behavior CMake Error at CMakeLists.txt:52 (target_link_libraries):
Target "react-native-keys" links to:

  ReactAndroid::reactnativejni

but the target was not found.  Possible reasons include:

  * There is a typo in the target name.
  * A find_package call is missing for an IMPORTED target.
  * An ALIAS target is missing.

Platform
Android

React Native Version
76.0 - New Arch Enabled

React Native Compressor Version
Latest Version.

@numandev1 - Check it out when you have free time please.

We use both of your packages in production apps. Thanks for the great work. We are grateful for your work.

Copy link

👋 @Gautham495
Thanks for opening your issue here! If you find this package useful hit the star🌟!

@efstathiosntonas
Copy link
Contributor

efstathiosntonas commented Oct 28, 2024

Hey @Gautham495, I’ve opened a draft PR to adress this but it’s not finished yet, got sick and stopped working on it 🫤

#84

@numandev1 can you pick up this PR and finish the remaining chages? Thanks

@efstathiosntonas
Copy link
Contributor

react-native-keys+0.7.10.patch

diff --git a/node_modules/react-native-keys/android/CMakeLists.txt b/node_modules/react-native-keys/android/CMakeLists.txt
index f453363..8f262ec 100644
--- a/node_modules/react-native-keys/android/CMakeLists.txt
+++ b/node_modules/react-native-keys/android/CMakeLists.txt
@@ -9,6 +9,7 @@ set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
 if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
     # Consume shared libraries and headers from prefabs
     find_package(ReactAndroid REQUIRED CONFIG)
+    find_package(fbjni REQUIRED CONFIG)  # Add this line to find fbjni

     include_directories(
         ${PACKAGE_NAME}
@@ -49,7 +50,17 @@ if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)

     find_package(openssl REQUIRED CONFIG)

-    target_link_libraries(
+    if (REACTNATIVE_MERGED_SO OR ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
+     target_link_libraries(
+        ${PACKAGE_NAME}
+        ${LOG_LIB}
+        ReactAndroid::reactnative
+        ReactAndroid::jsi
+        fbjni::fbjni
+        openssl::crypto
+      )
+    else()
+      target_link_libraries(
         ${PACKAGE_NAME}
         ${LOG_LIB}
         ReactAndroid::jsi
@@ -57,7 +68,8 @@ if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
         ReactAndroid::react_nativemodule_core
         android
         openssl::crypto
-    )
+     )
+    endif()
 else()
     add_library(
         ${PACKAGE_NAME}

@Gautham495
Copy link
Author

@efstathiosntonas

I confirm this is working thanks a lot.

@tarakagilefoways
Copy link

@efstathiosntonas could you please release a fix as i can confirm above patch is working fine.

@efstathiosntonas
Copy link
Contributor

@tarakagilefoways I have already opened a PR about it, there’s nothing else I can do about this: #84

@ishan-sharma-me
Copy link

ishan-sharma-me commented Dec 16, 2024

this is happening when i am adding find_package(fbjni REQUIRED CONFIG) in CMakeLists.txt
@efstathiosntonas I am getting this error while trying to build

* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
   > 2 files found with path 'lib/armeabi-v7a/libreactnative.so' from inputs:
      - /Users/flek/projects/flek/flek/node_modules/react-native-keys/android/build/intermediates/library_jni/debug/copyDebugJniLibsProjectOnly/jni/armeabi-v7a/libreactnative.so
      - /Users/flek/.gradle/caches/8.10.2/transforms/846b353864b4165ea31cf10ddf9cdbf4/transformed/react-android-0.76.3-debug/jni/armeabi-v7a/libreactnative.so
     If you are using jniLibs and CMake IMPORTED targets, see
     https://developer.android.com/r/tools/jniLibs-vs-imported-targets

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


would you know way to fix this?

@HamoBoker
Copy link

@ishan-sharma-me

add "**/libreactnative.so" to excludes in ~/react-native-keys/android/build.gradle

  packagingOptions {
    excludes = [
      "**/libc++_shared.so",
      "**/libfbjni.so",
      "**/libreactnative.so",
      "**/libreactnativejni.so",
      "**/libjsi.so",
      "**/libreact_nativemodule_core.so",
      "**/libturbomodulejsijni.so",
      "**/MANIFEST.MF"
    ]
    doNotStrip '**/*.so'
  }

and then clean the build and it should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants