android-notes / Cockroach

降低Android非必要crash
MIT License
3.25k stars 449 forks source link

发现错误 java.lang.IllegalStateException #23

Closed liulance closed 6 years ago

liulance commented 6 years ago

Layout state should be one of 100 but it is 10

com.wanjian.cockroach.Cockroach$1.run(Cockroach.java:47) 你好,bugly 上报了这个错误,请问是啥原因,谢谢

android-notes commented 6 years ago

完整错误发我下 @liulance

liulance commented 6 years ago

@android-notes

1 android.support.v7.widget.RecyclerView$State.assertLayoutStep(RecyclerView.java:11683)

2 android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3736) 3 android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3447) 4 android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3988) 5 android.view.View.layout(View.java:15928) 6 android.view.ViewGroup.layout(ViewGroup.java:5110) 7 android.widget.FrameLayout.layoutChildren(FrameLayout.java:633) 8 android.widget.FrameLayout.onLayout(FrameLayout.java:568) 9 android.view.View.layout(View.java:15928) 10 android.view.ViewGroup.layout(ViewGroup.java:5110) 11 android.widget.FrameLayout.layoutChildren(FrameLayout.java:633) 12 android.widget.FrameLayout.onLayout(FrameLayout.java:568) 13 android.view.View.layout(View.java:15928) 14 android.view.ViewGroup.layout(ViewGroup.java:5110) 15 android.widget.LinearLayout.setChildFrame(LinearLayout.java:1959) 16 android.widget.LinearLayout.layoutVertical(LinearLayout.java:1813) 17 android.widget.LinearLayout.onLayout(LinearLayout.java:1722) 18 android.view.View.layout(View.java:15928) 19 android.view.ViewGroup.layout(ViewGroup.java:5110) 20 android.widget.FrameLayout.layoutChildren(FrameLayout.java:633) 21 android.widget.FrameLayout.onLayout(FrameLayout.java:568) 22 android.view.View.layout(View.java:15928) 23 android.view.ViewGroup.layout(ViewGroup.java:5110) 24 android.widget.LinearLayout.setChildFrame(LinearLayout.java:1959) 25 android.widget.LinearLayout.layoutVertical(LinearLayout.java:1813) 26 android.widget.LinearLayout.onLayout(LinearLayout.java:1722) 27 android.view.View.layout(View.java:15928) 28 android.view.ViewGroup.layout(ViewGroup.java:5110) 29 android.widget.FrameLayout.layoutChildren(FrameLayout.java:633) 30 android.widget.FrameLayout.onLayout(FrameLayout.java:568) 31 android.view.View.layout(View.java:15928) 32 android.view.ViewGroup.layout(ViewGroup.java:5110) 33 android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2474) 34 android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2166) 35 android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1290) 36 android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6520) 37 android.view.Choreographer$CallbackRecord.run(Choreographer.java:821) 38 android.view.Choreographer.doCallbacks(Choreographer.java:624) 39 android.view.Choreographer.doFrame(Choreographer.java:593) 40 android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:807) 41 android.os.Handler.handleCallback(Handler.java:815) 42 android.os.Handler.dispatchMessage(Handler.java:104) 43 android.os.Looper.loop(Looper.java:194) 44 com.wanjian.cockroach.Cockroach$1.run(Cockroach.java:47) 45 android.os.Handler.handleCallback(Handler.java:815) 46 android.os.Handler.dispatchMessage(Handler.java:104) 47 android.os.Looper.loop(Looper.java:194) 48 android.app.ActivityThread.main(ActivityThread.java:5581) 49 java.lang.reflect.Method.invoke(Native Method) 50 java.lang.reflect.Method.invoke(Method.java:372) 51 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:968) 52 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:763)

android-notes commented 6 years ago

onMayBeBlackScreen中没有杀进程吧 @liulance

liulance commented 6 years ago

需要在哪里杀死进程?能否详细告知下,谢谢

android-notes commented 6 years ago

view绘制过程(measure,layout,draw)包括recyclerview onbindview中抛出异常可能会导致什么都不显示,这种情况会调用onMayBeBlackScreen。比如当前A act中的recyclerview中bindview时抛出了异常,这时虽然该recyclerview还可以滚动,点击,并且可以返回到上一个act时,但如果从A act打开新的act B,然后关闭B返回A时,可能A就什么都不显示了,并且这时再次按返回按键的话可能无法关闭A,不好判断到底是哪个act中的view抛出的异常,所以建议杀进程 。

你用的是2.0版本还是1.0的 @liulance

open9527 commented 6 years ago

直接在activity/fragment中执行 int i= Integer.valueOf(null); 这种代码好像不能防止AppCrash.

android-notes commented 6 years ago

生命周期抛出的异常会关闭act,但不会终止进程 @open9527