Scrapped or attached views may not be recycled.
See original GitHub issueHi there,
I have a bunch of errors like this in crashlytics. I’m using EpoxyControllers, with animateLayout set to false in xml. I’ve been trying to eradicate them, I was using adapters at first, and moved to controller in the hope that it will fix it. I can reproduce sometimes when animating then killing the activity but it’s pretty random. Any hints what I should look at?
Thanks

Exception java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true ca.example.application.clean.view.androidviews.NoLeakRecyclerView{56aba42 VFED..... .F....ID 0,300-720,1040 #7f0800e5 app:id/content_messaging_ad_overview_conversationList}, adapter:com.airbnb.epoxy.j@8a2300, layout:android.support.v7.widget.LinearLayoutManager@37b1739, context:ca.example..application.components.messagingadoverview.MessagingAdOverviewActivity@f67d7df
android.support.v7.widget.RecyclerView$Recycler.convertPreLayoutPositionToPostLayout (RecyclerView.java)
android.support.v7.widget.RecyclerView.access$000 (RecyclerView.java)
android.support.v7.widget.RecyclerView$ItemAnimatorRestoreListener.onAnimationFinished (RecyclerView.java)
android.support.v7.widget.RecyclerView$ItemAnimator.dispatchAnimationFinished (RecyclerView.java)
android.support.v7.widget.SimpleItemAnimator.dispatchMoveFinished (SimpleItemAnimator.java)
android.support.v7.widget.DefaultItemAnimator$6.onAnimationEnd (DefaultItemAnimator.java)
android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd (ViewPropertyAnimator.java:1121)
android.animation.ValueAnimator.endAnimation (ValueAnimator.java:1149)
android.animation.ValueAnimator.doAnimationFrame (ValueAnimator.java:1309)
android.animation.AnimationHandler.doAnimationFrame (AnimationHandler.java:146)
android.animation.AnimationHandler.-wrap2 (AnimationHandler.java)
android.animation.AnimationHandler$1.doFrame (AnimationHandler.java:54)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:957)
android.view.Choreographer.doCallbacks (Choreographer.java:734)
android.view.Choreographer.doFrame (Choreographer.java:667)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:945)
android.os.Handler.handleCallback (Handler.java:751)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6776)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1518)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)
Exception java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true ca.example.application.clean.view.androidviews.NoLeakRecyclerView{9da5955 VFED..... .F...... 0,0-1080,1113 #7f08007f app:id/contentPublicProfileAdsRecyclerView}, adapter:com.airbnb.epoxy.EpoxyControllerAdapter@334899f, layout:android.support.v7.widget.GridLayoutManager@f473aec, context:ca.example.application.components.publicprofile.PublicProfileActivity@5609d7d
android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal (RecyclerView.java:5864)
android.support.v7.widget.RecyclerView$Recycler.recycleView (RecyclerView.java:5808)
android.support.v7.widget.GapWorker.prefetchPositionWithDeadline (GapWorker.java:292)
android.support.v7.widget.GapWorker.flushTaskWithDeadline (GapWorker.java:342)
android.support.v7.widget.GapWorker.flushTasksWithDeadline (GapWorker.java:358)
android.support.v7.widget.GapWorker.prefetch (GapWorker.java:365)
android.support.v7.widget.GapWorker.run (GapWorker.java:396)
android.os.Handler.handleCallback (Handler.java:751)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6776)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1518)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)
<ca.example.application.clean.view.androidviews.NoLeakRecyclerView
android:id="@+id/content_messaging_ad_overview_conversationList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="false"
/>
open class NoLeakRecyclerView : RecyclerView {
constructor(context: Context): super(context)
constructor(context: Context, attrs: AttributeSet): super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int): super(context, attrs, defStyleAttr)
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
adapter = null
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
RecyclerView crashes when "scrapped or attached views may ...
There are a number of reason why this exception is called. In my case it was due to animations running thats why the...
Read more >Scrapped or attached views may not be recycled. isScrap ...
Bug report Summary java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true ...
Read more >IllegalArgumentException: Scrapped or attached views may ...
java.lang.IllegalArgumentException : Scrapped or attached views may not be recycled. isScrap:false isAttached:true android.support.v7.widget.
Read more >Android : RecyclerView crashes when "scrapped or attached ...
Android : RecyclerView crashes when " scrapped or attached views may not be recycled " [ Beautify Your Computer ...
Read more >Scrapped or attached views may not be recycled. isScrap ...
IllegalArgumentException : Scrapped or attached views may not be recycled. isScrap:false isAttached:true com.cider.widget.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Great! thank you for following up 😃
@vdubedout Hey, thx for sharing! No new crashes till now? Could you detail how to ‘remove’ the TransitionManager.beginDelayedTransition in RecyclerView?