CoordinatorLayout NullPointerException in onTouchEvent

自作多情 提交于 2019-12-04 04:05:28

According to the link posed by Kevin Salazar, the bug is fixed if you update your support library to version 23.0.1

This works for me. https://code.google.com/p/android/issues/detail?id=183166

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    try {
        return super.dispatchTouchEvent(ev);
    } catch (Exception e) {
        return false;
    }
}

As David Chu correctly explains, the issue is resolved in versions 23.0.1 and upwards. Also, in my case, Kevin Salazar's suggestion of try-catching the dispatchTouchEvent seemed to lower (could be perception bias) the number of crashes but not completely avoid them.

A key aspect is that the crash is not as random as it appears at first. In my case it occurs when you SLOWLY slide the drawer open. Quickly opening and closing the drawer does not result in a crash. This was helpful for me to reproduce the bug.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!