Skip to content

Build fails when using @react-native-community/javascriptcore instead of Hermes #8547

@emjeku

Description

@emjeku

Description

Starting from react-native version 0.80 javascript core was removed as a runtime, and instead @react-native-community/javascriptcore is suggested to use. For performance reasons we need to do that, but this is incompatible with react-native-reanimated.
The build fails with a CMake error related to ReactAndroid::jsctooling.

Expected Behavior
App should build and run successfully using @react-native-community/javascriptcore instead of Hermes.

Actual Behavior
Build fails with the following CMake errors:

Execution failed for task ':react-native-reanimated:configureCMakeDebug[arm64-v8a]'.
CMake Error at src/main/cpp/worklets/CMakeLists.txt:16 (add_library):
  Target "worklets" links to target "ReactAndroid::jsctooling" but the target
  was not found.
  Perhaps a find_package() call is missing for an IMPORTED target,
  or an ALIAS target is missing?

CMake Error at src/main/cpp/reanimated/CMakeLists.txt:10 (add_library):
  Target "reanimated" links to target "ReactAndroid::jsctooling" but the target
  was not found.

This seems to be the result from:

target_link_libraries(worklets ReactAndroid::jsctooling)

react-native removed jsctooling for external jsc versions with facebook/react-native#49365

This is also an issue with the New Architecture enabled and react-native-reanimated version 4.

How do you make react-native-reanimated work with @react-native-community/javascriptcore?
Any help or suggestions would be greatly appreciated!

Steps to reproduce

  1. Download the repository created from the following steps:
    a. Create a React Native Comunity CLI project.
    b. Install @react-native-community/javascriptcore and update Gradle files.
    c. Install react-native-reanimated.
  2. Run the app: npx react-native run-android.
  3. Observe the build failure during the CMake configuration step in react-native-reanimated.

Snack or a link to a repository

https://github.com/emjeku/test-react-native-reanimated-with-jsc-community

Reanimated version

3.19.3

Worklets version

React Native version

0.81.4

Platforms

Android

JavaScript runtime

JSC

Workflow

React Native CLI

Architecture

Legacy Architecture (Paper renderer)

Reanimated feature flags

No

React Native release level

Stable

Build type

Debug app & dev bundle

Device

Real device

Host machine

Linux

Device model

Samsung Galaxy A51 Android 13

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform: AndroidThis issue is specific to AndroidRepro providedA reproduction with a snippet of code, snack or repo is provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions