question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] FATAL EXCEPTION java.lang.ArrayIndexOutOfBoundsException

See original GitHub issue

The 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:closed
  • Created 4 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

32reactions
crobinson42commented, Aug 13, 2019

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.

3reactions
kubilaykiymacicommented, Aug 22, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found