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.

ArrayIndexOutOfBoundsException in updateLayoutState()

See original GitHub issue

Hi, I have a crash from time to time when updating data. It looks like updateLayoutState() throws an IndexOutOfBoundsException here:

FlexboxLayoutManager line 2057

int firstVisiblePosition = getPosition(firstVisible);
int firstVisibleLinePosition = mFlexboxHelper.mIndexToFlexLine[firstVisiblePosition];

getPosition(firstVisible) seems to return -1 (NO_POSITION) sometimes. Maybe this is related to the activity being hidden behind another. It happens at least on versions 0.3.0 and 0.3.1

Here is the full stacktrace:

java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
    at com.google.android.flexbox.FlexboxLayoutManager.updateLayoutState(FlexboxLayoutManager.java:2058)
    at com.google.android.flexbox.FlexboxLayoutManager.handleScrollingCrossAxis(FlexboxLayoutManager.java:1930)
    at com.google.android.flexbox.FlexboxLayoutManager.fixLayoutEndGap(FlexboxLayoutManager.java:825)
    at com.google.android.flexbox.FlexboxLayoutManager.onLayoutChildren(FlexboxLayoutManager.java:762)
    at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3693)
    at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3109)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.support.v7.widget.CardView.onMeasure(CardView.java:218)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
    at android.view.View.measure(View.java:19857)
    at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1293)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.widget.ScrollView.onMeasure(ScrollView.java:340)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:400)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at com.android.internal.policy.DecorView.onMeasure(DecorView.java:689)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2275)
    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1366)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1675)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
    at android.view.Choreographer.doCallbacks(Choreographer.java:686)
    at android.view.Choreographer.doFrame(Choreographer.java:621)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:23 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
Evgeny-Rogachevcommented, Sep 18, 2018

I have the same problem and it often crash my app. Please fix this issue.

2reactions
ajh8894commented, Jun 24, 2019

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

debugging - can't find the problem with java.lang ...
Looking at the source of BasicListUI.updateLayoutState() , this can only happen when the list being displayed changes size while the method ...
Read more >
ArrayIndexOutOfBoundsException (Java SE 19 & JDK 19)
Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal...
Read more >
JList cause an exception when exclusively add data to the list
ArrayIndexOutOfBoundsException : 59614 at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1155) ... getContentPane().add(list);
Read more >
146448 – ArrayIndexOutOfBoundsException: 3
setModel() called outside AWT (1.40 KB, text/plain) ... updateLayoutState(BasicListUI.java:1356) at javax.swing.plaf.basic.BasicListUI.
Read more >
Source for java.lang.ArrayIndexOutOfBoundsException
1: /* ArrayIndexOutOfBoundsException.java -- exception thrown when accessing 2: ... 63: */ 64: public ArrayIndexOutOfBoundsException() 65: { 66: } 67: 68: ...
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