🐛 Reanimated 4 Compatibility
What's happening?
Reanimated 4 uses react-native-worklets https://docs.swmansion.com/react-native-reanimated/docs/next/
iOS builds fine with both react-native-worklets and react-native-worklets-core` (required for frame processors). However on Android get the below error.
Reproduceable Code
N/A
Relevant log output
> Task :react-native-vision-camera:configureCMakeDebug[arm64-v8a]
C/C++: VisionCamera: Frame Processors: ON!
C/C++: VisionCamera: Linking react-native-worklets...
> Task :app:compileDevDebugJavaWithJavac FAILED
/Users/Documents/Code/apps/mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:72: error: a type with the same simple name is already defined by the single-type-import of WorkletsPackage
import com.worklets.WorkletsPackage;
^
/Users/Documents/Code/apps/mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:154: error: reference to WorkletsPackage is ambiguous new WorkletsPackage(), ^ both class com.swmansion.worklets.WorkletsPackage in com.swmansion.worklets and class com.worklets.WorkletsPackage in com.worklets match
/Users/Documents/Code/apps/mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:155: error: reference to WorkletsPackage is ambiguous new WorkletsPackage(), ^ both class com.swmansion.worklets.WorkletsPackage in com.swmansion.worklets and class com.worklets.WorkletsPackage in com.worklets match
3 errors FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':app:compileDevDebugJavaWithJavac'.
> Compilation failed; see the compiler output below. /Users/Documents/Code/apps/mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:72: error: a type with the same simple name is already defined by the single-type-import of WorkletsPackage import com.worklets.WorkletsPackage; ^ /Users/Documents/Code/apps/mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:154: error: reference to WorkletsPackage is ambiguous new WorkletsPackage(), ^ both class com.swmansion.worklets.WorkletsPackage in com.swmansion.worklets and class com.worklets.WorkletsPackage in com.worklets match /Users/Documents/Code/apps/mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:155: error: reference to WorkletsPackage is ambiguous new WorkletsPackage(), ^ both class com.swmansion.worklets.WorkletsPackage in com.swmansion.worklets and class com.worklets.WorkletsPackage in com.worklets match 3 errors * Try:
> Check your code and dependencies to fix the compilation error(s)
> Run with --scan to get full insights. BUILD FAILED in 1m 36s.
Camera Device
N/A
Device
Android
VisionCamera Version
4.7.0
Can you reproduce this issue in the VisionCamera Example app?
I didn't try (⚠️ your issue might get ignored & closed if you don't try this)
Additional information
- [x] I am using Expo
- [x] I have enabled Frame Processors (react-native-worklets-core)
- [x] I have read the Troubleshooting Guide
- [x] I agree to follow this project's Code of Conduct
- [x] I searched for similar issues in this repository and found none.
Guten Tag, Hans here! 🍻
Thanks for your detailed report, but I see some issues. It seems you did not provide a reproducible code sample or relevant logs related to your Android build errors. Also, it would be helpful for you to test your issue in the VisionCamera Example app, as mentioned.
Please check your dependencies and ensure they are set up correctly, especially regarding react-native-worklets. For logs, run adb logcat while reproducing the issue to get more insights and share those here.
If you're still having trouble, you might also consider sponsoring the project here for prioritized support.
Looking forward to more information!
Note: If you think I made a mistake, please ping
@mrousavyto take a look.
This /example/src/CameraPage.tsx needs update too as Reanimated 4 removed useAnimatedGestureHandler.
While iOS builds fine, the interaction of the worklets is kind of broken with frame processors. Because the babel plugin for react-native-worklets and react-native-worklets-core use the same tag, they are mutually exclusive... and therefore use react-native-worklets (because react-native-reanimated/skia/etc depend) ... so, while the frameprocessor worklets run in the core runtime, the code is generated for the other runtime, and many cross-boundary APIs do not work... furthermore, if you enable the new bundle-mode in react-native-worklets, it crashes the app as vision-camera inits.