java.lang.ArrayIndexOutOfBoundsException: length=4; index=4 #7

Closed
opened 2013-04-19 17:39:04 +02:00 by Amab · 2 comments
Amab commented 2013-04-19 17:39:04 +02:00 (Migrated from github.com)

java.lang.ArrayIndexOutOfBoundsException: length=4; index=4
at es.ugr.swad.swadroid.modules.notifications.NotificationsCursorAdapter.bindView(NotificationsCursorAdapter.java:229)
at android.widget.CursorAdapter.getView(CursorAdapter.java:250)
at android.widget.AbsListView.obtainView(AbsListView.java:2445)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1250)
at android.widget.ListView.onMeasure(ListView.java:1162)
at android.view.View.measure(View.java:15473)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
at android.view.View.measure(View.java:15473)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:15473)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
at android.view.View.measure(View.java:15473)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2361)
at android.view.View.measure(View.java:15473)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1974)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1217)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1390)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)

java.lang.ArrayIndexOutOfBoundsException: length=4; index=4 at es.ugr.swad.swadroid.modules.notifications.NotificationsCursorAdapter.bindView(NotificationsCursorAdapter.java:229) at android.widget.CursorAdapter.getView(CursorAdapter.java:250) at android.widget.AbsListView.obtainView(AbsListView.java:2445) at android.widget.ListView.measureHeightOfChildren(ListView.java:1250) at android.widget.ListView.onMeasure(ListView.java:1162) at android.view.View.measure(View.java:15473) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396) at android.widget.LinearLayout.measureVertical(LinearLayout.java:681) at android.widget.LinearLayout.onMeasure(LinearLayout.java:574) at android.view.View.measure(View.java:15473) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:15473) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396) at android.widget.LinearLayout.measureVertical(LinearLayout.java:681) at android.widget.LinearLayout.onMeasure(LinearLayout.java:574) at android.view.View.measure(View.java:15473) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2361) at android.view.View.measure(View.java:15473) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1974) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1217) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1390) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) at android.view.Choreographer.doCallbacks(Choreographer.java:555) at android.view.Choreographer.doFrame(Choreographer.java:525) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4898) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) at dalvik.system.NativeStart.main(Native Method)
lu-ym commented 2016-10-09 02:50:34 +02:00 (Migrated from github.com)

I also have this question. Could you talk about how to fix it, or how it happened? Thanks so much!

I also have this question. Could you talk about how to fix it, or how it happened? Thanks so much!
Amab commented 2016-10-09 11:05:31 +02:00 (Migrated from github.com)

Hi @lu-ym.

I'm using the cursor position as an index to access an array the same size as the result set. When the cursor reaches the end of the result set, the cursor position is END + 1.

At this time, the array is accessed through the array[END + 1] sentence, whose index is outside the bounds of the array, and an exception ArrayIndexOutOfBoundsException occurs.

As you can see in the commit 1c59e4f, I fixed it by checking the index value before accessing the array.

Hi @lu-ym. I'm using the cursor position as an index to access an array the same size as the result set. When the cursor reaches the end of the result set, the cursor position is _END + 1_. At this time, the array is accessed through the `array[END + 1]` sentence, whose index is outside the bounds of the array, and an exception ArrayIndexOutOfBoundsException occurs. As you can see in the commit 1c59e4f, I fixed it by checking the index value before accessing the array.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Marown/SWADroid#7
No description provided.