Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing when i use recyclerview in fragments #42

Open
Prashanthlkv opened this issue Sep 27, 2015 · 5 comments
Open

Crashing when i use recyclerview in fragments #42

Prashanthlkv opened this issue Sep 27, 2015 · 5 comments

Comments

@Prashanthlkv
Copy link

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)

@wasabeef
Copy link
Owner

wasabeef commented Oct 1, 2015

@Prashanthlkv

Please your code.

@ramden
Copy link

ramden commented Nov 13, 2015

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,
.......

@renyedi
Copy link

renyedi commented Jun 9, 2016

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)

@renyedi
Copy link

renyedi commented Jun 27, 2016

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.

@jason1114
Copy link

@renyedi Exactly the right answer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants