recyclerview-animators
recyclerview-animators copied to clipboard
Crashing when i use recyclerview in fragments
java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true 09-27 11:07:30.772 25402-25402/mobile.bikerenterzowner E/AndroidRuntime: at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:4705) 09-27 11:07:30.772 25402-25402/mobile.bikerenterzowner E/AndroidRuntime: at android.support.v7.widget.RecyclerView.removeAnimatingView(RecyclerView.java:1050) 09-27 11:07:30.772 25402-25402/mobile.bikerenterzowner E/AndroidRuntime: at android.support.v7.widget.RecyclerView.access$5300(RecyclerView.java:141) 09-27 11:07:30.772 25402-25402/mobile.bikerenterzowner E/AndroidRuntime: at android.support.v7.widget.RecyclerView$ItemAnimatorRestoreListener.onAddFinished(RecyclerView.java:9622) 09-27 11:07:30.772 25402-25402/mobile.bikerenterzowner E/AndroidRuntime: at android.support.v7.widget.RecyclerView$ItemAnimator.dispatchAddFinished(RecyclerView.java:9967) 09-27 11:07:30.772 25402-25402/mobile.bikerenterzowner E/AndroidRuntime: at jp.wasabeef.recyclerview.animators.BaseItemAnimator$DefaultAddVpaListener.onAnimationEnd(BaseItemAnimator.java:645)
@Prashanthlkv
Please your code.
For me too when using in fragment.
Code is standard recyclerview in fragment with adapter like here: https://www.youtube.com/watch?v=MHqpR3yLNfk
11-12 18:58:03.022 26703-26703/de.demoapp.app E/AndroidRuntime: FATAL EXCEPTION: main 11-12 18:58:03.022 26703-26703/de.demoapp.app E/AndroidRuntime: Process: de.demoapp.app, PID: 26703 11-12 18:58:03.022 26703-26703/de.demoapp.app E/AndroidRuntime: java.lang.AbstractMethodError: abstract method "boolean android.support.v7.widget.RecyclerView$ItemAnimator.animateAppearance(android.support.v7.widget.RecyclerView$ViewHolder, android.support.v7.widget.RecyclerView$ItemAnimator$ItemHolderInfo, .......
I also started seeing these occasionally with recyclerview-animators-2.2.3, com.android.support:recyclerview-v7:23.4.0 on Genymotion (Nexus 5 running Android 5.1). As it stands right now, I can't reproduce it :-( Will add more details in case I can. Preventively adding android:focusableInTouchMode="true"
and android:animateLayoutChanges="false"
to my recyclerview, as hinted at from several stackoverflow threads.
This is my stack trace:
06-09 01:00:16.762 20948-20948/com.ebay.napp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.ebay.napp, PID: 20948 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:4878) at android.support.v7.widget.RecyclerView.removeAnimatingView(RecyclerView.java:1127) at android.support.v7.widget.RecyclerView.access$6400(RecyclerView.java:147) at android.support.v7.widget.RecyclerView$ItemAnimatorRestoreListener.onAnimationFinished(RecyclerView.java:10294) at android.support.v7.widget.RecyclerView$ItemAnimator.dispatchAnimationFinished(RecyclerView.java:10794) at android.support.v7.widget.SimpleItemAnimator.dispatchRemoveFinished(SimpleItemAnimator.java:265) at jp.wasabeef.recyclerview.animators.BaseItemAnimator$DefaultRemoveVpaListener.onAnimationEnd(BaseItemAnimator.java:690) at android.support.v4.view.ViewPropertyAnimatorCompatJB$1.onAnimationEnd(ViewPropertyAnimatorCompatJB.java:47) at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1116) at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1171) at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:722) at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738) 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:5254) 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:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
The fix which worked for me: do not reuse the same animator instance across multiple recycler view instances!
I had a static field referring the animator instance. I was creating two instances of the fragment containing the recycler view, but I also noticed the issue when the single fragment instance got recycled and a another instance created.
@renyedi Exactly the right answer!