java.lang.IndexOutOfBoundsException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

Try to use notifyDataSetChanged() instead of notifyItemRemoved(), there's a bug in RecyclerView and notifyItemRemoved() does not work in some environments.

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • Bug Report
    via GitHub by hyb1996
    ,
  • GitHub comment 198#216004873
    via GitHub by MDXDave
    ,
  • GitHub comment 5#245264376
    via GitHub by andansky
    ,
    • java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{34e69164 position=0 id=-1, oldPos=1, pLpos:1 scrap [attachedScrap] tmpDetached no parent} at android.support.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:5220) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5402) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5363) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5359) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2141) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1525) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1488) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:585) at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3457) at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:2963) at android.view.View.measure(View.java:17928) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698) at android.widget.FrameLayout.onMeasure(FrameLayout.java:465) at android.view.View.measure(View.java:17928) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:846) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:512) at android.view.View.measure(View.java:17928) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698) at android.widget.FrameLayout.onMeasure(FrameLayout.java:465) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139) at android.view.View.measure(View.java:17928) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698) at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:393) at android.view.View.measure(View.java:17928) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698) at android.widget.FrameLayout.onMeasure(FrameLayout.java:465) at android.view.View.measure(View.java:17928) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1723) at android.widget.LinearLayout.measureVertical(LinearLayout.java:785) at android.widget.LinearLayout.onMeasure(LinearLayout.java:654) at android.view.View.measure(View.java:17928) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698) at android.widget.FrameLayout.onMeasure(FrameLayout.java:465) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2745) at android.view.View.measure(View.java:17928) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2412) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1414) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1638) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1292) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6598) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:800) at android.view.Choreographer.doCallbacks(Choreographer.java:603) at android.view.Choreographer.doFrame(Choreographer.java:572) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:786) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5682) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor2 times, last one,
    Agócs TamásAgócs Tamás
    1 times, last one,
    Unknown visitor
    Unknown visitor3 times, last one,
    27 more bugmates