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

前端 未结 10 2243
青春惊慌失措
青春惊慌失措 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:25

    Override dispatchDraw method and put in it a try/catch block, like this:

    public void dispatchDraw(Canvas c)
        {
            try
            {
                super.dispatchDraw(c);
                return;
    
            }
            catch(Exception exception)
            {
                return;
            }
        }
    

提交回复
热议问题