react-native-reanimated: [android] v3.0.0-rc.2 does not compile with monorepo

Description

If you have fabric enabled in a monorepo, you won’t be able to build. The error is caused by this path assumption

https://github.com/software-mansion/react-native-reanimated/blob/main/android/CMakeLists.txt#L33

The workaround is to go in and amend it, but obviously it requires a much better solution

diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt
index 835ed09db19b696cf0eb62e3e0c13e7d77e04e0b..3758ed50ca0c4d5951a7bd9dc96fb3e85eb9cf47 100644
--- a/android/CMakeLists.txt
+++ b/android/CMakeLists.txt
@@ -33,7 +33,7 @@ endif()
 
 if(${IS_NEW_ARCHITECTURE_ENABLED})
     if(${CLIENT_SIDE_BUILD})
-        set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../../../android/app/build/react-ndk/exported")
+        set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../../../mobile-app/android/app/build/react-ndk/exported")
         set (FBJNI_HEADERS_DIR "${CMAKE_SOURCE_DIR}/../../react-native/ReactAndroid/src/main/jni/first-party/fbjni/headers")
     else()
         set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../${PLAYGROUND_APP_NAME}/android/app/build/react-ndk/exported")

Steps to reproduce

  1. setup a monorepo
  2. activate fabric
  3. build the app

Snack or a link to a repository

Reanimated version

3.0.0-rc.2

React Native version

0.70.0

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

Android emulator

Device model

No response

Acknowledgements

Yes

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 15 (6 by maintainers)

Most upvoted comments

@andreibarabas I’m having the same issue in our monorepo build with react-native-reanimatedv3.0.0rc.3 We had to make a similar edit as you did. Ours is as follows:

if(${IS_NEW_ARCHITECTURE_ENABLED})
    if(${CLIENT_SIDE_BUILD})
-        set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../../../android/app/build/react-ndk/exported")
+        set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../../../packages/${PLAYGROUND_APP_NAME}/android/app/build/react-ndk/exported")
         set (FBJNI_HEADERS_DIR "${CMAKE_SOURCE_DIR}/../../react-native/ReactAndroid/src/main/jni/first-party/fbjni/headers")
    else()
         set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../${PLAYGROUND_APP_NAME}/android/app/build/react-ndk/exported")

This issue is currently unresolved!

glad to see it was usefull @capezzbr

Regarding how I debugged it, i started printing the build variables in the logs and then figured out which one was wrong.