当我在应用程序被杀死后重新启动应用程序时出现致命异常(android)
当我在应用程序被杀死后重新启动应用程序时(被 android 杀死大约一个小时后或者如果我通过任务杀手杀死它),应用程序崩溃并显示以下消息:
10-23 09:07:41.120: 错误/AndroidRuntime(647): 致命异常:main 10-23 09:07:41.120: 错误/AndroidRuntime(647): java.lang.RuntimeException: 无法启动活动 ComponentInfo{ com.test.testapp /com.test.testapp.TestingActivity}: java.lang.NullPointerException 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 android.app.ActivityThread.access$2300(ActivityThread.java:125) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 android.os.Handler.dispatchMessage(Handler.java:99) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 android.os.Looper.loop(Looper.java:123) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 android.app.ActivityThread.main(ActivityThread.java:4627) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 java.lang.reflect.Method.invokeNative(本机方法) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 java.lang.reflect.Method.invoke(Method.java:521) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 10-23 09:07:41.120:错误/AndroidRuntime(647):在dalvik.system.NativeStart.main(本机方法) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 原因: java.lang.NullPointerException 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 com.test.testapp.TestingActivity.onCreate(TestingActivity.java:178) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 10-23 09:07:41.120: 错误/AndroidRuntime(647): 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
我在该活动中有一个计时器,我想它可能与该线程有关但即使我删除计时器它仍然崩溃。我真的不明白这里出了什么问题。有什么想法吗?
提前致谢
When I restart my app after its been killed (after an hour or so by android or if I kill it via task killer), the app crashes with the following message:
10-23 09:07:41.120: ERROR/AndroidRuntime(647): FATAL EXCEPTION: main
10-23 09:07:41.120: ERROR/AndroidRuntime(647): java.lang.RuntimeException: Unable to start activity ComponentInfo{ com.test.testapp /com.test.testapp.TestingActivity}: java.lang.NullPointerException
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at android.os.Handler.dispatchMessage(Handler.java:99)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at android.os.Looper.loop(Looper.java:123)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at java.lang.reflect.Method.invokeNative(Native Method)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at java.lang.reflect.Method.invoke(Method.java:521)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at dalvik.system.NativeStart.main(Native Method)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): Caused by: java.lang.NullPointerException
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at com.test.testapp.TestingActivity.onCreate(TestingActivity.java:178)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-23 09:07:41.120: ERROR/AndroidRuntime(647): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
I have a timer in that activity and I thought maybe it had something to do with that thread but even if I remove the timer it still crashes. I really can't figure out what's wrong here. Any ideas?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Android 会回收内存。您需要检查它不为空。它也说哪条线也在抱怨
Android will reclaim memory. You need to check it's not null. It says which line is complaining too