[Android] FATAL EXCEPTION java.lang.ArrayIndexOutOfBoundsException
See original GitHub issueThe Android app is crashing when reseting items and value at the same time.
In my app I have 3 dropdown which depend on each other, every time I try change the value from the first, I need to reset the items and value of the 2 others, and when that happen on Android the app crashed right away.
Expected behavior
By clearing the items array and the value, the picker should display the picker without any items.
Smartphone (please complete the following information):
- Device: All of them
- OS: Android
- react-native-picker-select version: 6.3.0
- react-native version: 0.60.4
- react version: 16.8.6
Logs
07-30 17:30:34.390 E unknown ReactNative: Exception in native call
07-30 17:30:34.390 E unknown ReactNative: java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
07-30 17:30:34.390 E unknown ReactNative: at java.util.Arrays$ArrayList.get(Arrays.java:3769)
07-30 17:30:34.390 E unknown ReactNative: at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:393)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.views.picker.ReactPickerManager$ReactPickerAdapter.getView(ReactPickerManager.java:116)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.views.picker.ReactPickerManager$ReactPickerAdapter.getView(ReactPickerManager.java:107)
07-30 17:30:34.390 E unknown ReactNative: at android.widget.Spinner.makeView(Spinner.java:712)
07-30 17:30:34.390 E unknown ReactNative: at android.widget.Spinner.layout(Spinner.java:660)
07-30 17:30:34.390 E unknown ReactNative: at android.widget.AbsSpinner.setSelectionInt(AbsSpinner.java:306)
07-30 17:30:34.390 E unknown ReactNative: at android.widget.AbsSpinner.setSelection(AbsSpinner.java:283)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.views.picker.ReactPicker.commitStagedData(ReactPicker.java:142)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.views.picker.ReactPickerManager.onAfterUpdateTransaction(ReactPickerManager.java:80)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.views.picker.ReactPickerManager.onAfterUpdateTransaction(ReactPickerManager.java:36)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:47)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties(NativeViewHierarchyManager.java:139)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.uimanager.UIViewOperationQueue$UpdatePropertiesOperation.execute(UIViewOperationQueue.java:93)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:844)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:952)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.uimanager.UIViewOperationQueue.access$2200(UIViewOperationQueue.java:44)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1012)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:172)
07-30 17:30:34.390 E unknown ReactNative: at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:84)
07-30 17:30:34.390 E unknown ReactNative: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:947)
07-30 17:30:34.390 E unknown ReactNative: at android.view.Choreographer.doCallbacks(Choreographer.java:761)
07-30 17:30:34.390 E unknown ReactNative: at android.view.Choreographer.doFrame(Choreographer.java:693)
07-30 17:30:34.390 E unknown ReactNative: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
07-30 17:30:34.390 E unknown ReactNative: at android.os.Handler.handleCallback(Handler.java:873)
07-30 17:30:34.390 E unknown ReactNative: at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 17:30:34.390 E unknown ReactNative: at android.os.Looper.loop(Looper.java:193)
07-30 17:30:34.390 E unknown ReactNative: at android.app.ActivityThread.main(ActivityThread.java:6669)
07-30 17:30:34.390 E unknown ReactNative: at java.lang.reflect.Method.invoke(Native Method)
07-30 17:30:34.390 E unknown ReactNative: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
07-30 17:30:34.390 E unknown ReactNative: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
07-30 17:30:34.393 D AndroidRuntime Shutting down VM
07-30 17:30:34.393 E AndroidRuntime FATAL EXCEPTION: main
07-30 17:30:34.393 E AndroidRuntime java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
07-30 17:30:34.393 E AndroidRuntime at java.util.Arrays$ArrayList.get(Arrays.java:3769)
07-30 17:30:34.393 E AndroidRuntime at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:393)
07-30 17:30:34.393 E AndroidRuntime at com.facebook.react.views.picker.ReactPickerManager$ReactPickerAdapter.getView(ReactPickerManager.java:116)
07-30 17:30:34.393 E AndroidRuntime at com.facebook.react.views.picker.ReactPickerManager$ReactPickerAdapter.getView(ReactPickerManager.java:107)
07-30 17:30:34.393 E AndroidRuntime at android.widget.Spinner.makeView(Spinner.java:712)
07-30 17:30:34.393 E AndroidRuntime at android.widget.Spinner.layout(Spinner.java:660)
07-30 17:30:34.393 E AndroidRuntime at android.widget.Spinner.onLayout(Spinner.java:622)
07-30 17:30:34.393 E AndroidRuntime at com.facebook.react.views.picker.ReactPicker.onLayout(ReactPicker.java:98)
07-30 17:30:34.393 E AndroidRuntime at android.view.View.layout(View.java:20672)
07-30 17:30:34.393 E AndroidRuntime at android.view.ViewGroup.layout(ViewGroup.java:6194)
07-30 17:30:34.393 E AndroidRuntime at com.facebook.react.views.picker.ReactPicker$2.run(ReactPicker.java:81)
07-30 17:30:34.393 E AndroidRuntime at android.os.Handler.handleCallback(Handler.java:873)
07-30 17:30:34.393 E AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 17:30:34.393 E AndroidRuntime at android.os.Looper.loop(Looper.java:193)
07-30 17:30:34.393 E AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:6669)
07-30 17:30:34.393 E AndroidRuntime at java.lang.reflect.Method.invoke(Native Method)
07-30 17:30:34.393 E AndroidRuntime at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
07-30 17:30:34.393 E AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
android - FATAL EXCEPTION: main java.lang ... - Stack Overflow
FATAL EXCEPTION : main java.lang.ArrayIndexOutOfBoundsException: · Look at your Adapter instantiation. The arrays for the data keys and the View ...
Read more >ArrayIndexOutOfBoundsException - Android Developers
java.util.concurrent.atomic ... public class ArrayIndexOutOfBoundsException ... Constructs an ArrayIndexOutOfBoundsException with no detail message.
Read more >java.lang.ArrayIndexOutOfBoundsException: com.google ...
FATAL EXCEPTION : java.lang. ... Android Studio version: 4.1; Firebase Component: Firebase ... The error is still happening on the latest ...
Read more >How to Fix java.lang.ArrayIndexOutOfBoundsException in ...
java.lang.ArrayIndexOutOfBoundsException length=0 index=0. This is the classic case of accessing an empty array. Since length is zero it means the array is ...
Read more >3 Tips to solve and Avoid java.lang ... - Javarevisited
The error ArrayIndexOutOfBoundsException: 1 means index 1 is invalid and it's out of bounding i.e. more than the length of the array. Since...
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
Workaround Solution
Someone on my team found another solution to this problem - you can pass
key={items.length}
to this component which will causes it to remount on render when the items.length changes.it works, thank you