【发布时间】:2017-12-23 16:29:25
【问题描述】:
我已经构建了集成 YouTube API 的应用程序,它运行良好,没有任何崩溃,但在 Fabric 上我检查了一些崩溃,它是 ipf.onFilterTouchEventForSecurity。以下是崩溃的完整日志:
java.lang.NullPointerException:
at ipf.onFilterTouchEventForSecurity(ipf.java:115)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2351)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2876)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2840)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1853)
at android.app.Activity.dispatchTouchEvent(Activity.java:3061)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2801)
at android.view.View.dispatchPointerEvent(View.java:10246)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5447)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5283)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4774)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4740)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4882)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4748)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4939)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4774)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4740)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4748)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7429)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7298)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7259)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7539)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java:0)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
我知道这个问题不是因为代码,但我需要防止崩溃。
以下是我遇到问题的设备列表:
- 三星 Galaxy J7 (j7elte),1536MB RAM,Android 6.0
- 小米红米 Note 3 (kenzo),2048MB RAM,Android 6.0
- 联想 TB3-710F (TB3-710F),1024MB RAM,Android 5.0
- 小米红米3S(陆上),2048MB内存,安卓6.0
- 乐视 Le 2 (le_s2_ww),3072MB RAM,Android 6.0
- LGE LG Stylus2 4G (ph2),2048MB RAM,Android 6.0
- Infocus M2_3G (G10),10124MB RAM,Android 4.4
【问题讨论】:
-
您是否尝试禁用触摸过滤以确保安全。来自文档
To enable touch filtering, call setFilterTouchesWhenObscured(boolean) or set the android:filterTouchesWhenObscured layout attribute to true. When enabled, the framework will discard touches that are received whenever the view's window is obscured by another visible window. As a result, the view will not receive touches whenever a toast, dialog or other window appears above the view's window. -
您好 Faisal,您能告诉我您是如何解决它或如何重现此错误的吗?我有同样的错误
-
@ErezShmiel 抱歉,问题尚未解决。
-
你写了
I know that this issue is not because of code当然是关于你的代码。 ANullPointerException被抛出,因为您的代码正在使用未实例化的对象。要么您调用某个方法来获取对象并且返回对象为空(因为您的代码未能传递正确/有效的参数),要么您的代码声明了一个对象并且您的代码在构造之前使用了它。这基本上就是 NPE。 -
@FaisalShaikh 我详细检查了日志。但是,我不需要检查日志,因为我完全知道
NullPointerException是什么。我建议你阅读 Izan Ali 的评论并点击他提供的链接。
标签: java android nullpointerexception