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.

  • Crash on 2.1.3
    via GitHub by dalb8
    ,
  • RecyclerView IndexOutOfBoundsException
    via Stack Overflow by jihoon kim
    ,
  • GitHub comment 198#216515357
    via GitHub by pepitoria
    ,
    • java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{25b4ab3e position=3 id=-1, oldPos=2, pLpos:2 scrap [attachedScrap] tmpDetached no parent} at android.support.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:4499) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4630) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4611) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1988) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1384) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1347) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574) at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:2977) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2901) at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1457) at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:147) at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:285) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:549) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5319) 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:1016) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Stefan BrauneStefan Braune
    11 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    27 more bugmates