当我在应用程序被杀死后重新启动应用程序时出现致命异常(android)

发布于 2024-12-11 07:51:45 字数 2151 浏览 0 评论 0原文

当我在应用程序被杀死后重新启动应用程序时(被 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪心 2024-12-18 07:51:45

Android 会回收内存。您需要检查它不为空。它也说哪条线也在抱怨

Android will reclaim memory. You need to check it's not null. It says which line is complaining too

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文