Android ViewGroup crash: Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference

前端 未结 10 2210
青春惊慌失措
青春惊慌失措 2020-12-08 00:15

We have found several cases for this kind of crashes reported by backend logging monitoring. It seems the crashes do not tie to particular UX failure. And from the reports,

10条回答
  •  粉色の甜心
    2020-12-08 00:42

    Possible cause: I was having the exact same issue. It turned out it started to happen when I added code to modify the view tree within onDraw() call. To be specific, I removed a view with children in my derived onDraw() when certain conditions were met. I now believe this is a bad thing to do, probably because the platform is trying to draw views that I have now removed from the view tree. I resolved the issue by posting the deletion with Runnable to happen after the call to onDraw() has finished.

提交回复
热议问题