java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

,
Expert tip

Thrown to indicate that an index of some sort (such as to an array, to a string, or to a vector) is out of range. Applications can subclass this class to indicate similar exceptions.

,

Thrown if trying to access an index which is out of bounds on objects like String, Array, or Vector. Any negative integer less than or equal to -1 and positive integer greater than or equal to the size of the object is an index which would be out of bounds

Solutions on the web

via GitHub by totiherms
, 1 year ago
Invalid index 2, size is 2
via GitHub by Sigvent
, 1 year ago
Invalid index 2, size is 2
via Stack Overflow by Vaishali Goel
, 1 year ago
via Stack Overflow by wviana
, 1 year ago
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2023)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2350)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2040)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2350)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2040)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2350)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2040)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2350)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2040)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2350)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2040)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2350)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2040)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2350)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2040)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2350)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2216)
at android.view.View.dispatchPointerEvent(View.java:8003)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4221)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4100)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3658)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3712)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3681)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3792)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3689)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3849)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3658)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3712)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3681)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3689)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3658)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5925)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5874)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5845)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6005)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:138)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:5584)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)

Users with the same issue

4 times, 3 months ago
Once, 4 months ago
3 times, 7 months ago
12 times, 7 months ago
81 times, 7 months ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.