JNI DETECTED ERROR IN APPLICATION: JNI GetObjectRefType called with pending exception java.lang.RuntimeException: java.lang.AssertionError: Illegal type provided
See original GitHub issueDescription
The worklets in Reanimated v2 seems to be really unstable in Android. Every change in the worklet code crashes the app and the app needs to be restarted like 5 times (crashes 5 times). And if you have an error in the worklet (e.g. calling any standard javascript function like parseInt, Math.round etc) it crashes in the native code with always the same error.
If I move the code from onEnd worklet to a normal function and call it with runOnJS it either does nothing or the app crashes. Is runOnJS even supposed to work?
java_vm_ext.cc:578] JNI DETECTED ERROR IN APPLICATION: JNI GetObjectRefType called with pending exception java.lang.RuntimeException: java.lang.AssertionError: Illegal type provided
java_vm_ext.cc:578] at void com.swmansion.reanimated.AndroidErrorHandler.raise(java.lang.String) (AndroidErrorHandler.java:6)
java_vm_ext.cc:578] at void com.swmansion.reanimated.Scheduler.triggerUI() (Scheduler.java:-2)
java_vm_ext.cc:578] at void com.swmansion.reanimated.Scheduler$1.run() (Scheduler.java:24)
Expected behavior
Crashes would be captured and a stack trace printed to the console. Or a proper error in the native logs. And when restarting the app after fixing the code (or not changing it at all when no bug in the code) the app would work in immediately not after 5 to 10 restarts (some caching issue?).
Actual behavior & steps to reproduce
Unhandled crashes and no proper recovery.
Snack or minimal code example
I’m using the pan gesture handler worklets with Samsung Galaxy A51 5G (SM-A516B).
Package versions
- React Native: 0.66.3
- React Native Reanimated: 2.3.0
- React Native Gesture Handler: 2.1.0
- NodeJS: 14.18.1
- Java & Gradle: OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing) & 7.3
Affected platforms
- Android
- iOS
- Web
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:12 (3 by maintainers)

Top Related StackOverflow Question
Hi @priyanka17-maker @andreialecu @tapz
I would like to share with you my solution for my case.
PROBLEM Works fine on debug builds for both Android and iOS, but crash on Android release - iOS on release build still works fine.
REASON I figure out that android crash because of useAnimatedStyle objects that are applied to the animated.view component on first mount.
HACK FIX for a problem For Android only - I created special state with effect to delay applying animatedstyle objects to the components. Simple timeout with 500 ms (value is just random - just not apply style object on first mount) - and no crash appear on android
Effect looks like that:
Then applying style objects looks like that:
I hope this will help you somehow - and maybe it will help to detect the real reason for this crash on Android.
@Lukkub I haven’t changed anything. It has always crashed only in debug builds after the first reload. And in iOS, it has never worker in the debug or the release build (but the reason and error is different than in Android).
Here is an example that works perfectly in Android, but not at all in iOS:
https://github.com/tapz/reanimatederror-example