java.lang.IllegalArgumentException

Scrapped or attached views may not be recycled. isScrap:false isAttached:true

Samebug tips2

This happens when you have android:animateLayoutChanges set to true in your XML file and you call notifyDataSetChanged(). To fix it, you have to set android:animateLayoutChanges to false.


rafaelrafael

In your xml just avoid using android:animateLayoutChanges with RecyclerViews.and also if you have set android:focusableInTouchMode="true" in your RecycleView you have to set false.

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web39

  • via Stack Overflow by Ivan Samsonov
    ,
  • via GitHub by jjhesk
    ,
  • Stack trace

    • java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:4860) at android.support.v7.widget.RecyclerView.removeAnimatingView(RecyclerView.java:1102) at android.support.v7.widget.RecyclerView.access$6400(RecyclerView.java:147) at android.support.v7.widget.RecyclerView$ItemAnimatorRestoreListener.onAnimationFinished(RecyclerView.java:10260) at android.support.v7.widget.RecyclerView$ItemAnimator.dispatchAnimationFinished(RecyclerView.java:10760) at android.support.v7.widget.SimpleItemAnimator.dispatchChangeFinished(SimpleItemAnimator.java:304) at android.support.v7.widget.DefaultItemAnimator$7.onAnimationEnd(DefaultItemAnimator.java:362) at android.support.v4.view.ViewPropertyAnimatorCompatJB$1.onAnimationEnd(ViewPropertyAnimatorCompatJB.java:47) at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1114) at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1239) at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:766) at android.animation.ValueAnimator$AnimationHandler$1.run(ValueAnimator.java:801) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) at android.view.Choreographer.doCallbacks(Choreographer.java:670) at android.view.Choreographer.doFrame(Choreographer.java:603) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

    Write tip

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

    Users with the same issue

    Hiren AmaliyarHiren Amaliyar
    8 times, last one
    rafaelrafael
    Once,
    mrokay97mrokay97
    12 times, last one
    Unknown visitor
    Unknown visitorOnce,
    Unknown visitor
    Unknown visitorOnce,
    6 more bugmates