android 5.0中的开关出错

时间:2014-12-08 13:21:42

标签: android android-5.0-lollipop

Hello Guys我使用的是从代码而不是xml创建的开关。 但只有在android 5.0中我才能在其他版本中得到这个错误,它的工作正常。

12-08 08:48:30.417: E/InputEventReceiver(31006): Exception dispatching input event.
12-08 08:48:30.417: E/MessageQueue-JNI(31006): Exception in MessageQueue callback: handleReceiveCallback
12-08 08:48:46.449: E/MessageQueue-JNI(31006): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.drawable.Drawable.getPadding(android.graphics.Rect)' on a null object reference
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.widget.Switch.hitThumb(Switch.java:694)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.widget.Switch.onTouchEvent(Switch.java:711)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.View.dispatchTouchEvent(View.java:8388)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2314)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1692)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.app.Activity.dispatchTouchEvent(Activity.java:2739)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2275)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.View.dispatchPointerEvent(View.java:8578)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4021)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3887)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3578)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3635)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5701)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5675)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5646)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5791)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.os.MessageQueue.nativePollOnce(Native Method)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.os.MessageQueue.next(MessageQueue.java:143)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.os.Looper.loop(Looper.java:122)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at android.app.ActivityThread.main(ActivityThread.java:5223)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at java.lang.reflect.Method.invoke(Native Method)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at java.lang.reflect.Method.invoke(Method.java:372)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
12-08 08:48:46.449: E/MessageQueue-JNI(31006):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
12-08 08:48:55.673: E/ACRA(31006): ACRA caught a NullPointerException exception for com.sa.appinboxtest. Building report.

1 个答案:

答案 0 :(得分:1)

这是Android报告的错误。如果您想修复此问题,请添加以下属性以切换

android:thumb="@drawable/my_thumb_icon"
android:track="@drawable/my_track_icon"

这也适用于5.0以下

供参考Click here