I am getting NullPointerException
in onTouchEvent
of CoordinatorLayout
.
I am using DrawerLayout
with CollapsingToolbarLayout
of android support AppCompat v23.0.0 library.
My observation is crash happen randomly while scrolling CollapsingToolbarLayout
or click on drawer items.
Is there anyone facing this issue? any work around to avoid this exception?
Logcat:
08-22 15:16:34.657: E/AndroidRuntime(27596): java.lang.NullPointerException: Attempt to invoke virtual method 'float android.view.MotionEvent.getX()' on a null object reference
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.view.View.onTouchEvent(View.java:9321)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.support.design.widget.CoordinatorLayout.onTouchEvent(CoordinatorLayout.java:449)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.view.View.dispatchTouchEvent(View.java:8388)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2398)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2158)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.support.v4.widget.DrawerLayout.cancelChildViewTouch(DrawerLayout.java:1491)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.support.v4.widget.DrawerLayout$ViewDragCallback.peekDrawer(DrawerLayout.java:1739)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.support.v4.widget.DrawerLayout$ViewDragCallback.access$000(DrawerLayout.java:1624)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.support.v4.widget.DrawerLayout$ViewDragCallback$1.run(DrawerLayout.java:1630)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.os.Handler.handleCallback(Handler.java:739)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.os.Handler.dispatchMessage(Handler.java:95)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.os.Looper.loop(Looper.java:135)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.app.ActivityThread.main(ActivityThread.java:5221)
08-22 15:16:34.657: E/AndroidRuntime(27596): at java.lang.reflect.Method.invoke(Native Method)
08-22 15:16:34.657: E/AndroidRuntime(27596): at java.lang.reflect.Method.invoke(Method.java:372)
08-22 15:16:34.657: E/AndroidRuntime(27596): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
08-22 15:16:34.657: E/AndroidRuntime(27596): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
08-22 15:16:35.965: I/Process(27596): Sending signal. PID: 27596 SIG: 9
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;
}
}
According to the link posed by Kevin Salazar, the bug is fixed if you update your support library to version 23.0.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With