react-native-picker / picker

Picker is a cross-platform UI component for selecting an item from a list of options.
MIT License
1.52k stars 289 forks source link

Android Fatal Native Exception #220

Closed kevinvangelder closed 3 years ago

kevinvangelder commented 3 years ago

When attempting to open the picker on Android, I get:

Fatal native exception java.lang.IllegalArgumentException: Unable to find JSIModule for class UIManager
    at com.facebook.react.bridge.JSIModuleRegistry.getModule(JSIModuleRegistry.java:24)
    at com.facebook.react.bridge.CatalystInstanceImpl.getJSIModule(CatalystInstanceImpl.java:564)
    at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:90)
    at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:46)
    at com.facebook.react.uimanager.UIManagerHelper.getUIManagerForReactTag(UIManagerHelper.java:40)
    at com.facebook.react.animated.NativeAnimatedNodesManager.handleEvent(NativeAnimatedNodesManager.java:505)
    at com.facebook.react.animated.NativeAnimatedNodesManager.onEventDispatch(NativeAnimatedNodesManager.java:483)
    at com.facebook.react.uimanager.events.EventDispatcherImpl.dispatchEvent(EventDispatcherImpl.java:116)
    at com.facebook.react.uimanager.JSTouchDispatcher.handleTouchEvent(JSTouchDispatcher.java:74)
    at com.facebook.react.ReactRootView.dispatchJSTouchEvent(ReactRootView.java:283)
    at com.facebook.react.ReactRootView.onInterceptTouchEvent(ReactRootView.java:201)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2609)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3060)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2698)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3060)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2698)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3060)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2698)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3060)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2698)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3060)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2698)
    at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:465)
    at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1849)
    at android.app.Activity.dispatchTouchEvent(Activity.java:3993)
    at com.gasbuddy.MainActivity.dispatchTouchEvent(MainActivity.java:43)
    at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
    at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:423)
    at android.view.View.dispatchPointerEvent(View.java:13674)
    at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5482)
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5285)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4788)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4841)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4807)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4947)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4815)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5004)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4788)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4841)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4807)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4815)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4788)
    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7505)
    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7474)
    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7435)
    at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7630)
    at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:188)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:336)
    at android.os.Looper.loop(Looper.java:174)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

React: 17.0.1 React Native: 0.64.0-rc4 React Native Picker: 1.9.11

sylvainbaronnet commented 3 years ago

Same issue, I reported it here : https://github.com/lawnstarter/react-native-picker-select/issues/422

fabOnReact commented 3 years ago

@sylvainbaronnet https://youtu.be/QwoQgzBgJu8?t=946

kevinvangelder commented 3 years ago

@sylvainbaronnet Your issue has a lot more info in it, I'll close mine in favor of yours.

sylvainbaronnet commented 3 years ago

@kevinvangelder I recommend you to keep it opens because mine is on another package

natwallbank commented 3 years ago

Are you using this with @react-navigation? I've just had this same issue since upgrading to 0.64 and found that this problem occurred on screens where I had enabled gestures (gestureEnabled: true in screenOptions).

ghost commented 3 years ago

(gestureEnabled: true in screenOptions).

You save me 👍

kevinvangelder commented 3 years ago

@natwallbank Yes I am, thanks for the info.

kevinvangelder commented 3 years ago

Sadly, this fix doesn't work for me as the picker is in a MaterialTopTabNavigator and swipeEnabled={false} doesn't resolve the crash. As far as I can tell, gesturesEnabled isn't a valid option for a TabNavigator.

natwallbank commented 3 years ago

Sadly, this fix doesn't work for me as the picker is in a MaterialTopTabNavigator and swipeEnabled={false} doesn't resolve the crash. As far as I can tell, gesturesEnabled isn't a valid option for a TabNavigator.

Is that MaterialTopTabNavigator referenced as a Screen? If so, you can supply it as options there I think?

kevinvangelder commented 3 years ago

@natwallbank Good thought. I gave that a shot and I'm still getting the native exception.

smontiu commented 3 years ago

I can confirm the issue, I just update my app and the test start to fail.

jonra1993 commented 3 years ago

I am facing the same issue. Have you guys have found any solution?

"react": "17.0.1" "react-native": "0.64.0" "@react-native-picker/picker": "^1.12.0"

jonra1993 commented 3 years ago

After lots of hours facing this issue our team discovered that in our case this package "react-native-snap-carousel" was causing the issue, I am not sure yet why but we deleted the carousel component and pickers of all the screens worked again. The really weird thing is that we used carousel package on different screens than pickers but when we go to any carousel view and return to picker view it fails.

sylvainbaronnet commented 3 years ago

I also use react-native-snap-carousel in the app that has this issue, on another one where we don't use that lib, the picker doesn't crash on Android.

jonra1993 commented 3 years ago

@sylvainbaronnet react-native-snap-carousel is causing that bug on the repository it has not been updated since May 2020, so we decided to use react-native-swiper-flatlist and react-native-fast-image instead our app is running again and pickers are working as is expected. Maybe for others facing this bug, the problem is in another depreciated package.

sylvainbaronnet commented 3 years ago

@jonra1993 Thanks a lot for the recommendation

jyotirmoym commented 3 years ago

I am facing the same issue. Has anybody found any solution?

"react": "17.0.1" "react-native": "0.64.0" "@react-native-picker/picker": "^1.12.0" "@react-navigation/native": "^5.9.3", "@react-navigation/stack": "^5.14.3",

I tried the approach mentioned by @natwallbank but it did not fix the issue.

smontiu commented 3 years ago

I am not using any kind of carousel, swipe, or moving component to affect or interfere with the picker itself. Picker's inside a View and that View inside a stack.

"react": "16.13.1", "react-native": "0.64.0", "@react-native-picker/picker": "^1.9.8", "@react-navigation/bottom-tabs": "^5.11.2", "@react-navigation/material-top-tabs": "^5.3.10", "@react-navigation/native": "^5.8.10", "@react-navigation/stack": "^5.12.8"

Jexim commented 3 years ago

I have the same problem with my project. Also, I use react-native-snap-carousel. I was trying to delete react-native-snap-carousel but it did not give a result.
So I'm not sure about it's related.

ehdwns980416 commented 3 years ago

Are you using this with @react-navigation? I've just had this same issue since upgrading to 0.64 and found that this problem occurred on screens where I had enabled gestures (gestureEnabled: true in screenOptions).

Awesome 🙇

mbouxin commented 3 years ago

Hi all the problem is from react-native and they are working on a fix. Basically their problem is because they try to use the id of the inflated picker while it is not set.

If it is of any use to someone, I temporarily fixed the problem on my project by making the following modifications

In TextViewImpl.java and CheckedTextViewImpl.java

4a5
> import android.view.View;
23a25,33
>     private View pickerView;
>     public int getId() {
>         return pickerView.getId();
>     }
> 
>     public void setPickerView(View pickerView) {
>         this.pickerView = pickerView;
>     }
> 

In ReactPickerManager.java

188a189,194
>       if (convertView instanceof TextViewImpl) {
>         ((TextViewImpl) convertView).setPickerView(parent);
>       } else if (convertView instanceof CheckedTextViewImpl) {
>         ((CheckedTextViewImpl) convertView).setPickerView(parent);
>       }
> 

It definitely is a bypass that should not be included in the sources but it solves the issue without changing used packages

allenmanning commented 3 years ago

they are working on a fix.

@mbouxin Do you happen to have an issue we can track on this?

mbouxin commented 3 years ago

they are working on a fix.

@mbouxin Do you happen to have an issue we can track on this?

https://github.com/facebook/react-native/issues/31245

mitrukahitesh commented 3 years ago

Are you using this with @react-navigation? I've just had this same issue since upgrading to 0.64 and found that this problem occurred on screens where I had enabled gestures (gestureEnabled: true in screenOptions).

gestureEnabled: false works. Thanks

LuizFBrisighello commented 3 years ago

Here is the commit that will be cherry picked for .64.2 facebook/react-native@b0e8c1e And thats the issue for the discussion https://github.com/react-native-community/releases/issues/224

hasibulHossain commented 3 years ago

Are you using this with @react-navigation? I've just had this same issue since upgrading to 0.64 and found that this problem occurred on screens where I had enabled gestures (gestureEnabled: true in screenOptions).

thank you, you save me

mikehardy commented 3 years ago

@kevinvangelder this is close-able react-native 0.64.2 is out with the fix for this included

Naturalclar commented 3 years ago

This was a bug on React Native's side, should be fixed on React Native 0.64.2