使用 ViewGroup 抛出 NullPointerException
有谁知道这可能是什么原因造成的?
11-16 16:23:26.745: ERROR/AndroidRuntime(9549): Uncaught handler: thread main exiting due to uncaught exception
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): java.lang.NullPointerException
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:692)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:692)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.view.ViewRoot.performTraversals(ViewRoot.java:722)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.view.ViewRoot.handleMessage(ViewRoot.java:1658)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.os.Handler.dispatchMessage(Handler.java:99)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.os.Looper.loop(Looper.java:123)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.app.ActivityThread.main(ActivityThread.java:4363)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at java.lang.reflect.Method.invokeNative(Native Method)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at java.lang.reflect.Method.invoke(Method.java:521)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at dalvik.system.NativeStart.main(Native Method)
Does anyone have a clue what could be causing this?
11-16 16:23:26.745: ERROR/AndroidRuntime(9549): Uncaught handler: thread main exiting due to uncaught exception
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): java.lang.NullPointerException
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:692)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:692)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.view.ViewRoot.performTraversals(ViewRoot.java:722)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.view.ViewRoot.handleMessage(ViewRoot.java:1658)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.os.Handler.dispatchMessage(Handler.java:99)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.os.Looper.loop(Looper.java:123)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at android.app.ActivityThread.main(ActivityThread.java:4363)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at java.lang.reflect.Method.invokeNative(Native Method)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at java.lang.reflect.Method.invoke(Method.java:521)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
11-16 16:23:26.765: ERROR/AndroidRuntime(9549): at dalvik.system.NativeStart.main(Native Method)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个错误过去经常出现在我们的崩溃报告中。追踪起来非常困难,但最后我们发现有时会触发代码,从 surfaceDestroyed()(SurfaceHolder 的回调方法)中删除视图层次结构中的视图。如果您的应用程序使用 SurfaceView,请确保您没有执行任何操作来修改 surfaceDestroyed() 中的视图层次结构。
This error used to show up in our crash reports with some regularity. It was very difficult to track down, but in the end we discovered that we sometimes triggered code that removed a view from the view hierarchy from surfaceDestroyed() (the callback method from SurfaceHolder). If your app is using a SurfaceView, make sure you don't do anything to modify the view hierarchy in surfaceDestroyed().