IllegalArgumentException pointerCount must be at least 1
See original GitHub issueDescription
Crash reported by our crash analytics tool. Reason is unknown, but this library shows in the stack trace.
Screenshots
Stack trace:
java.lang.IllegalArgumentException pointerCount must be at least 1
MotionEvent.java:-2 android.view.MotionEvent.nativeInitialize
MotionEvent.java:1706 android.view.MotionEvent.obtain
MotionEvent.java:1752 android.view.MotionEvent.obtain
GestureHandler.java:270 com.swmansion.gesturehandler.GestureHandler.adaptEvent
GestureHandler.java:295 com.swmansion.gesturehandler.GestureHandler.handle
GestureHandlerOrchestrator.java:301 com.swmansion.gesturehandler.GestureHandlerOrchestrator.deliverEventToGestureHandler
GestureHandlerOrchestrator.java:259 com.swmansion.gesturehandler.GestureHandlerOrchestrator.deliverEventToGestureHandlers
GestureHandlerOrchestrator.java:101 com.swmansion.gesturehandler.GestureHandlerOrchestrator.onTouchEvent
RNGestureHandlerRootHelper.java:126 com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper.dispatchTouchEvent
RNGestureHandlerEnabledRootView.java:36 com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView.dispatchTouchEvent
ViewGroup.java:3142 android.view.ViewGroup.dispatchTransformedTouchEvent
ViewGroup.java:2834 android.view.ViewGroup.dispatchTouchEvent
ViewGroup.java:3142 android.view.ViewGroup.dispatchTransformedTouchEvent
ViewGroup.java:2834 android.view.ViewGroup.dispatchTouchEvent
ViewGroup.java:3142 android.view.ViewGroup.dispatchTransformedTouchEvent
ViewGroup.java:2834 android.view.ViewGroup.dispatchTouchEvent
ViewGroup.java:3142 android.view.ViewGroup.dispatchTransformedTouchEvent
ViewGroup.java:2834 android.view.ViewGroup.dispatchTouchEvent
ViewGroup.java:3142 android.view.ViewGroup.dispatchTransformedTouchEvent
ViewGroup.java:2834 android.view.ViewGroup.dispatchTouchEvent
DecorView.java:495 com.android.internal.policy.DecorView.superDispatchTouchEvent
PhoneWindow.java:1868 com.android.internal.policy.PhoneWindow.superDispatchTouchEvent
Activity.java:4022 android.app.Activity.dispatchTouchEvent
WindowCallbackWrapper.java:69 androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent
DecorView.java:453 com.android.internal.policy.DecorView.dispatchTouchEvent
View.java:14261 android.view.View.dispatchPointerEvent
ViewRootImpl.java:5903 android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent
ViewRootImpl.java:5706 android.view.ViewRootImpl$ViewPostImeInputStage.onProcess
ViewRootImpl.java:5153 android.view.ViewRootImpl$InputStage.deliver
ViewRootImpl.java:5206 android.view.ViewRootImpl$InputStage.onDeliverToNext
ViewRootImpl.java:5172 android.view.ViewRootImpl$InputStage.forward
ViewRootImpl.java:5180 android.view.ViewRootImpl$InputStage.apply
ViewRootImpl.java:5153 android.view.ViewRootImpl$InputStage.deliver
ViewRootImpl.java:5206 android.view.ViewRootImpl$InputStage.onDeliverToNext
ViewRootImpl.java:5172 android.view.ViewRootImpl$InputStage.forward
ViewRootImpl.java:5328 android.view.ViewRootImpl$AsyncInputStage.forward
ViewRootImpl.java:5180 android.view.ViewRootImpl$InputStage.apply
ViewRootImpl.java:5385 android.view.ViewRootImpl$AsyncInputStage.apply
ViewRootImpl.java:5153 android.view.ViewRootImpl$InputStage.deliver
ViewRootImpl.java:5206 android.view.ViewRootImpl$InputStage.onDeliverToNext
ViewRootImpl.java:5172 android.view.ViewRootImpl$InputStage.forward
ViewRootImpl.java:5180 android.view.ViewRootImpl$InputStage.apply
ViewRootImpl.java:5153 android.view.ViewRootImpl$InputStage.deliver
ViewRootImpl.java:8002 android.view.ViewRootImpl.deliverInputEvent
ViewRootImpl.java:7969 android.view.ViewRootImpl.doProcessInputEvents
ViewRootImpl.java:7930 android.view.ViewRootImpl.enqueueInputEvent
ViewRootImpl.java:8156 android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent
InputEventReceiver.java:189 android.view.InputEventReceiver.dispatchInputEvent
InputEventReceiver.java:-2 android.view.InputEventReceiver.nativeConsumeBatchedInputEvents
InputEventReceiver.java:179 android.view.InputEventReceiver.consumeBatchedInputEvents
ViewRootImpl.java:8086 android.view.ViewRootImpl.doConsumeBatchedInput
ViewRootImpl.java:8180 android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run
Choreographer.java:1043 android.view.Choreographer$CallbackRecord.run
Choreographer.java:866 android.view.Choreographer.doCallbacks
Choreographer.java:794 android.view.Choreographer.doFrame
Choreographer.java:1028 android.view.Choreographer$FrameDisplayEventReceiver.run
Handler.java:883 android.os.Handler.handleCallback
Handler.java:100 android.os.Handler.dispatchMessage
Looper.java:214 android.os.Looper.loop
ActivityThread.java:7615 android.app.ActivityThread.main
Method.java:-2 java.lang.reflect.Method.invoke
RuntimeInit.java:492 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run
ZygoteInit.java:964 com.android.internal.os.ZygoteInit.main
Steps To Reproduce
Expected behavior
No crash.
Actual behavior
Random crash
Snack or minimal code example
I’m not using the library directly, but rather react-navigation is using it. However, the following code is used for initialization:
index.js
import 'react-native-gesture-handler';
... other imports and index code
MainActivity.java (as documented in the installation guide)
/**
For react-native-gesture-handler (used)
*/
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
Package versions
- React: 16.13.1
- React Native: 0.62.2
- React Native Gesture Handler: 1.8.0
- @react-navigation/compat: 5.2.5
- @react-navigation/native: 5.7.3
- @react-navigation/stack: 5.9.0
- Android: 10 (LG Stylo 6 (LM-Q730))
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:24 (5 by maintainers)
Top Results From Across the Web
IllegalArgumentException pointerCount must be at least 1
Coming soon: A brand new website interface for an even better experience!
Read more >core/jni/android_view_MotionEvent.cpp - Google Git
jniThrowException(env, "java/lang/IllegalArgumentException",. "pointerCount must be at least 1"); ... "pointerProperties array must not be null");.
Read more >Android- java.lang.IllegalArgumentException - Stack Overflow
1 Answer 1. Sorted by: Reset to default. Highest score (default) ...
Read more >java.lang.IllegalArgumentException: pointerIndex out of range ...
The problem occur only with Android 3.2. My code works properly with all previous versions. Cannot reproduce the problem myself.
Read more >Automating Mobile Gestures With UiAutomator2 Backend
If the element is missing then both click offset coordinates must be provided. ... The returned value is a boolean one and equals...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d be ok with merging a change that mitigates the issue. Seems like there are many people reporting it and no way for us to get a repro. Would suggest to make it so that it still crashes in DEV but not in PROD, this way there is still possibility for us to discover the reason of the crash in the future. Will defer to @j-piasecki for the final resolution
Hi!
You can fix this by adding
if (count == 0) return event; // Avoid crash in MotionEvent.obtain when count = 0
before
In
GestureHandler.java
,private MotionEvent adaptEvent(MotionEvent event)
, line 284.You can use attached patch with patch-package: Just follow setup instructions, unzip attached file and copy into Your project
patches
folder (create one if needed).react-native-gesture-handler+1.10.3.patch.zip