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

java.lang.IllegalStateException: Added View has RecyclerView as parent but view is not a real child. Unfiltered index:0 #147

Open
xingag opened this issue Aug 6, 2015 · 11 comments
Labels

Comments

@xingag
Copy link

xingag commented Aug 6, 2015

08-06 18:34:26.649 31234-31234/com.marshalchen.ultimaterecyclerview.demo E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.marshalchen.ultimaterecyclerview.demo, PID: 31234
java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
at java.util.ArrayList.remove(ArrayList.java:405)
at com.marshalchen.ultimaterecyclerview.UltimateViewAdapter.remove(UltimateViewAdapter.java:183)
at com.marshalchen.ultimaterecyclerview.demo.SimpleAdapter.remove(SimpleAdapter.java:80)
at com.marshalchen.ultimaterecyclerview.demo.SimpleAdapter.onItemDismiss(SimpleAdapter.java:157)
at com.marshalchen.ultimaterecyclerview.itemTouchHelper.SimpleItemTouchHelperCallback.onSwiped(SimpleItemTouchHelperCallback.java:76)
at android.support.v7.widget.helper.ItemTouchHelper$4.run(ItemTouchHelper.java:669)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
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:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)

@cymcsg
Copy link
Owner

cymcsg commented Aug 6, 2015

Could you tell me how to reappear this bug?

@xingag
Copy link
Author

xingag commented Aug 6, 2015

切换动画模式,然后多刷新几次,就报错了,不是必现的

@xingag
Copy link
Author

xingag commented Aug 6, 2015

是在下拉刷新的时候,同时做删除操作,引起的崩溃

@xingag
Copy link
Author

xingag commented Aug 7, 2015

08-07 09:43:25.195 26466-26466/com.marshalchen.ultimaterecyclerview.demo E/ViewRootImpl﹕ sendUserActionEvent() mView == null
08-07 09:43:33.155 26466-26466/com.marshalchen.ultimaterecyclerview.demo E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.marshalchen.ultimaterecyclerview.demo, PID: 26466
java.lang.IllegalStateException: Added View has RecyclerView as parent but view is not a real child. Unfiltered index:0
at android.support.v7.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:6017)
at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:5983)
at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:5971)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1373)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1322)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:556)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2673)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:2971)
at android.view.View.layout(View.java:16678)
at android.view.ViewGroup.layout(ViewGroup.java:5328)
at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:562)
at android.view.View.layout(View.java:16678)
at android.view.ViewGroup.layout(ViewGroup.java:5328)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1077)
at android.view.View.layout(View.java:16678)
at android.view.ViewGroup.layout(ViewGroup.java:5328)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:16678)
at android.view.ViewGroup.layout(ViewGroup.java:5328)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:16678)
at android.view.ViewGroup.layout(ViewGroup.java:5328)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:16678)
at android.view.ViewGroup.layout(ViewGroup.java:5328)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:16678)
at android.view.ViewGroup.layout(ViewGroup.java:5328)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:16678)
at android.view.ViewGroup.layout(ViewGroup.java:5328)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
at android.view.View.layout(View.java:16678)
at android.view.ViewGroup.layout(ViewGroup.java:5328)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:16678)
at android.view.ViewGroup.layout(ViewGroup.java:5328)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2319)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2032)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1191)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6643)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
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:1400)
at com.android.inte

,cause new bug,when i choose ADMob ListView Test,then Scroll and press the Del button, it cause
this Exception .

@cymcsg
Copy link
Owner

cymcsg commented Aug 7, 2015

You can disable the swipe gesture when the recyclerview refreshing if you want to solve it now.

@tuesda
Copy link

tuesda commented Nov 12, 2015

@cymcsg how to disable swipe gesture when recyclerview refreshing?

@crazymajax
Copy link

I had the same error and the solution for me was to no longer specify my own ids.
So I removed the following lines of code and it started working again:

  public MyAdapter(Context context) {
      this.context = context;
-     setHasStableIds(true)   // <----- removed this
  }

and all of this:

 -    @Override     
 -    public long getItemId(int position) {     
 -        return position;      
 -    }

@asdfcjf
Copy link

asdfcjf commented Jun 4, 2016

我也碰到这个错误了 是怎么解决的啊

@jjhesk
Copy link
Collaborator

jjhesk commented Sep 12, 2016

I have this found by v0.7.0

java.lang.IllegalStateException: Added View has RecyclerView as parent but view is not a real child. Unfiltered index:0

@cymcsg i have the same problem too. Do we need to roll-back to the previous version??

dependencies{
compile 'com.hkm.ui:ultimaterecyclerview:0.5.91'
}

@jjhesk jjhesk added the bug label Sep 12, 2016
@jjhesk jjhesk changed the title Cause Exception java.lang.IllegalStateException: Added View has RecyclerView as parent but view is not a real child. Unfiltered index:0 Sep 12, 2016
@cymcsg
Copy link
Owner

cymcsg commented Sep 13, 2016

How can I reappear the exception? By removing a item when the recyclerview is refreshing as @hush881025 said?
@jjhesk

hugonardo added a commit to hugonardo/RecyclerViewCursorAdapter that referenced this issue Oct 7, 2016
Based on links at final of description, a error can happen if there is
conflicted itemId in dataset. It may be caused if the adapter implements
a header or footer, when getItemId() returns 0.

Now, when is requested an id for a invalid position, a
RecyclerView.NO_ID is returned.

Links:

h6ah4i/android-advancedrecyclerview#164
cymcsg/UltimateRecyclerView#147
@hmedat
Copy link

hmedat commented Jul 16, 2017

Any updates regarding this issue?

I don't have any direct scenario to reproduce it, I got the this crash from Crashlytics

screen shot 2017-07-16 at 12 15 09 pm

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

No branches or pull requests

7 participants