Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoordinatorLayout crashes app with IndexOutOfBoundsException

I'm getting a crash (from Crashlytics, unable to reproduce locally) in my app from the onLayout function in the CoordinatorLayout:

Fatal Exception: java.lang.IndexOutOfBoundsException: Invalid index 3, size is 3
   at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
   at java.util.ArrayList.get(ArrayList.java:308)
   at android.support.design.widget.CoordinatorLayout.onLayout(SourceFile:848)
   at android.view.View.layout(View.java:15237)
   at android.view.ViewGroup.layout(ViewGroup.java:4864)
   at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
   at android.view.View.layout(View.java:15237)
   at android.view.ViewGroup.layout(ViewGroup.java:4864)
   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
   at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
   at android.view.View.layout(View.java:15237)
   at android.view.ViewGroup.layout(ViewGroup.java:4864)
   at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
   at android.view.View.layout(View.java:15237)
   at android.view.ViewGroup.layout(ViewGroup.java:4864)
   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
   at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
   at android.view.View.layout(View.java:15237)
   at android.view.ViewGroup.layout(ViewGroup.java:4864)
   at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
   at android.view.View.layout(View.java:15237)
   at android.view.ViewGroup.layout(ViewGroup.java:4864)
   at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2323)
   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2029)
   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1192)
   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6231)
   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:816)
   at android.view.Choreographer.doCallbacks(Choreographer.java:619)
   at android.view.Choreographer.doFrame(Choreographer.java:588)
   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:802)
   at android.os.Handler.handleCallback(Handler.java:808)
   at android.os.Handler.dispatchMessage(Handler.java:103)
   at android.os.Looper.loop(Looper.java:193)
   at android.app.ActivityThread.main(ActivityThread.java:5388)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:655)
   at dalvik.system.NativeStart.main(NativeStart.java)

Since I haven't been able to reproduce this myself and have 6 activities with CoordinatorLayouts, how can I go about debugging this?

Edit: looks like it will be fixed in the next support library release

like image 696
Daniel Rampelt Avatar asked Sep 02 '16 17:09

Daniel Rampelt


1 Answers

I had a similar issue, and downgrading to a older Android Support Library version(v24.1.1) worked for me. It's seems to be a problem in the Library, you can check the problem out the Android Issue Tracker here.

UPDATE 1 : Seems like it's going to be resolved in de next version of the Android Support Library(v24.2.1), thanks Daniel Rampelt for the update

UPDATE 2 : 24.2.1 is out as of today and the error seems to be resolved—at least I couldnae reproduce it with the current version. – PattaFeuFeu

UPDATE 3 : 24.2.1 introduced new bug: post – AAverin

like image 179
Bram Sinke Avatar answered Sep 20 '22 02:09

Bram Sinke