Android RecycleView异常

时间:2019-04-17 17:09:56

标签: android android-recyclerview recycler-adapter recyclerview-layout

我在Android上的Recyclerview中有一个令人讨厌的错误。

此错误发生在约0.5%的用户生产环境中,我无法在dev上重现它,并且由于它在某些内部Android调用中发生,我什至无法捕捉到异常以避免应用程序崩溃 >

exception是:

  

致命异常:java.lang.IndexOutOfBoundsException:不一致   检测到。无效的视图支架适配器positionViewHolder {bb8f997   位置= 7 id = -1,oldPos = 8,pLpos:7废料[attachedScrap] tmpDetached   没有父母} android.support.v7.widget.RecyclerView {b200eda VFED.V ...   ...... ID 0,146-684,423#7f0a0238 app:id / sponsorsRecyclerView},   适配器:com.tomatedigital.giveawaymaster.a.f@78d6257,   布局:android.support.v7.widget.GridLayoutManager@1739144,   上下文:com.tomatedigital.giveawaymaster.activity.NewGiveawayAct@cc2874a              在android.support.v7.widget.RecyclerView $ Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:5610)              在android.support.v7.widget.RecyclerView $ Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5792)              在android.support.v7.widget.RecyclerView $ Recycler.getViewForPosition(RecyclerView.java:5752)              在android.support.v7.widget.RecyclerView $ Recycler.getViewForPosition(RecyclerView.java:5748)              在android.support.v7.widget.LinearLayoutManager $ LayoutState.next(LinearLayoutManager.java:2232)              在android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556)              在android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519)              在android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614)              在android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)              在android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3763)              在android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3527)              在android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:4082)              在android.view.View.layout(View.java:21057)              在android.view.ViewGroup.layout(ViewGroup.java:6440)              在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)              在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)              在android.widget.LinearLayout.onLayout(LinearLayout.java:1544)              在android.view.View.layout(View.java:21057)              在android.view.ViewGroup.layout(ViewGroup.java:6440)              在android.support.v4.view.ViewPager.onLayout(ViewPager.java:1769)              在android.view.View.layout(View.java:21057)              在android.view.ViewGroup.layout(ViewGroup.java:6440)              在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)              在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)              在android.widget.LinearLayout.onLayout(LinearLayout.java:1544)              在android.view.View.layout(View.java:21057)              在android.view.ViewGroup.layout(ViewGroup.java:6440)              在android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)              在android.view.View.layout(View.java:21057)              在android.view.ViewGroup.layout(ViewGroup.java:6440)              在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)              在android.widget.FrameLayout.onLayout(FrameLayout.java:261)              在android.view.View.layout(View.java:21057)              在android.view.ViewGroup.layout(ViewGroup.java:6440)              在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)              在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)              在android.widget.LinearLayout.onLayout(LinearLayout.java:1544)              在android.view.View.layout(View.java:21057)              在android.view.ViewGroup.layout(ViewGroup.java:6440)              在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)              在android.widget.FrameLayout.onLayout(FrameLayout.java:261)              在android.view.View.layout(View.java:21057)              在android.view.ViewGroup.layout(ViewGroup.java:6440)              在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)              在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)              在android.widget.LinearLayout.onLayout(LinearLayout.java:1544)              在android.view.View.layout(View.java:21057)              在android.view.ViewGroup.layout(ViewGroup.java:6440)              在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)              在android.widget.FrameLayout.onLayout(FrameLayout.java:261)              在com.android.internal.policy.DecorView.onLayout(DecorView.java:966)              在android.view.View.layout(View.java:21057)              在android.view.ViewGroup.layout(ViewGroup.java:6440)              在android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3043)              在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2730)              在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1859)              在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:8087)              在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:911)              在android.view.Choreographer.doCallbacks(Choreographer.java:723)              在android.view.Choreographer.doFrame(Choreographer.java:658)              在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:897)              在android.os.Handler.handleCallback(Handler.java:790)              在android.os.Handler.dispatchMessage(Handler.java:99)              在android.os.Looper.loop(Looper.java:164)              在android.app.ActivityThread.main(ActivityThread.java:7000)              在java.lang.reflect.Method.invoke(Method.java)              在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:441)              在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

很抱歉,我没有太多信息可提供,但是对此Recyclerview ...没有什么特别的事情。

用户可以在视图列表的末尾添加项目
或可以删除​​他想要的任何位置的物品...在删除之前,我总是检查该职位是否有效
我总是在mainthread

处添加和删除

添加或删除后,我调用特定的Recyclerview方法来显示更改。

0 个答案:

没有答案