react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

[android] v3.0.0-rc.2 does not compile with monorepo

Open andreibarabas opened this issue 2 years ago • 6 comments

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

andreibarabas avatar Sep 15 '22 08:09 andreibarabas

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] avatar Sep 15 '22 08:09 github-actions[bot]

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Snack or a link to a repository section.

github-actions[bot] avatar Sep 15 '22 08:09 github-actions[bot]

@andreibarabas any solutions please ?

hamdij0maa avatar Sep 15 '22 11:09 hamdij0maa

Hey @hamdij0maa . See above the patch for the workaround. Obviously, you should make sure to replace 'mobile-app' with you actual folder name

Let me know if it works

andreibarabas avatar Sep 15 '22 14:09 andreibarabas

Hey @andreibarabas, thanks for submitting the issue and for the workaround! We definitely need to fix it on our side.

tomekzaw avatar Sep 15 '22 15:09 tomekzaw

Sounds good @tomekzaw

andreibarabas avatar Sep 16 '22 09:09 andreibarabas

I've been spending few hours trying to resolve this, thanks @andreibarabas for posting a solution! Can I ask you how you were able to debug the problem? 🙇

capezzbr avatar Oct 14 '22 01:10 capezzbr

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.

andreibarabas avatar Oct 14 '22 02:10 andreibarabas

Thanks for following up @andreibarabas 🙌 have you also managed to resolve this issue too https://github.com/software-mansion/react-native-reanimated/issues/3595?

capezzbr avatar Oct 14 '22 02:10 capezzbr

That one looks like a duplicate of this one. If the path is wrong, then the other variables will be empty. See if changing the path solves it for you

andreibarabas avatar Oct 14 '22 02:10 andreibarabas

That issue seem different. It seem that reanimated is referencing a Fabric directory, that is supposed to live under the package directory (you can see it in master https://github.com/software-mansion/react-native-reanimated/tree/main/Common/cpp/Fabric) but it isn't in version 2.10 (or at least not for me)

capezzbr avatar Oct 14 '22 03:10 capezzbr

Hey @andreibarabas , we just published 2.11.0 which hopefully should work fine in monorepo. Can you please upgrade and check if this resolves your issue?

tomekzaw avatar Oct 14 '22 08:10 tomekzaw

I believe this issue was reported for v3 not v2. Also, I've tested 2.11 in a monorepo, but the issue is still there, but at least Andrei patch does work

capezzbr avatar Oct 14 '22 17:10 capezzbr

How to deal with this problem now?thank you

mengbimao avatar Nov 06 '22 02:11 mengbimao

@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!

only1chi avatar Nov 16 '22 17:11 only1chi

Hi! I can happily inform you that as of the newest Reanimated versions, this issue is resolved!

szydlovsky avatar Jun 25 '24 12:06 szydlovsky