Skip to content

Conversation

@tomekzaw
Copy link
Member

@tomekzaw tomekzaw commented Jul 23, 2025

Summary

This PR fixes the following linking error `on Android due to undefined symbols when trying to build fabric-example via Android Studio after running Clean project after the app was built successfully.

ld.lld: error: undefined symbol: worklets::stringifyJSIValue(facebook::jsi::Runtime&, facebook::jsi::Value const&)

Previously, we would include react-native-worklets::worklets prefab but still build libworklets.so from source. Because of the way how Android Gradle Plugin works (ask @lukmccall for more details), libworklets would sometimes be treated like a header-only library with no shared object files, causing the aforementioned linking error.

The proposed solution is to abandon prefabs in favor of linking libworklets.so manually (using add_library) as well as passing additional header search paths (using target_include_directories).

Test plan

@tomekzaw tomekzaw requested a review from tjzel July 23, 2025 11:13
@tomekzaw tomekzaw marked this pull request as ready for review July 25, 2025 15:00
@tomekzaw tomekzaw added this pull request to the merge queue Jul 28, 2025
Merged via the queue into main with commit 2b4113f Jul 28, 2025
12 checks passed
@tomekzaw tomekzaw deleted the @tomekzaw/fix-linking-error-after-gradle-clean branch July 28, 2025 10:08
MatiPl01 pushed a commit that referenced this pull request Jul 28, 2025
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary

This PR fixes the following linking error `on Android due to undefined
symbols when trying to build fabric-example via Android Studio after
running Clean project after the app was built successfully.

<img alt=""
src="https://github.com/user-attachments/assets/a96dfc25-b039-4e0b-8a2f-0a88ef4703c2"
/>

```
ld.lld: error: undefined symbol: worklets::stringifyJSIValue(facebook::jsi::Runtime&, facebook::jsi::Value const&)
```

Previously, we would include `react-native-worklets::worklets` prefab
but still build `libworklets.so` from source. Because of the way how
Android Gradle Plugin works (ask @lukmccall for more details),
`libworklets` would sometimes be treated like a header-only library with
no shared object files, causing the aforementioned linking error.

The proposed solution is to abandon prefabs in favor of linking
`libworklets.so` manually (using `add_library`) as well as passing
additional header search paths (using `target_include_directories`).

## Test plan

<!-- Provide a minimal but complete code snippet that can be used to
test out this change along with instructions how to run it and a
description of the expected behavior. -->
MatiPl01 added a commit that referenced this pull request Jul 28, 2025
github-merge-queue bot pushed a commit that referenced this pull request Dec 2, 2025
## Summary

Follow-up to
- #7866

I accidentally found code from the following PR
- mrousavy/nitro#776

which fixes our prefab issues when running `Project Clean` then `Build`
in Android Studio.

## Test plan

1. Clean your repo with `git clean -Xdf`
2. Install deps with `yarn`
3. Open `apps/fabric-example/android` with AndroidStudio
4. Run build
5. Run clean
6. Run build (without this change here Reanimated would complain about
missing symbols)
7. 🥳
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants