简体   繁体   English

Android Stack Trace的解释

[英]Interpretation of Android Stack Trace

I received an error report with the following stack trace for an app I have in the Android Market: 我收到了一个错误报告,其中包含我在Android电子市场中拥有的应用的以下堆栈跟踪:

java.lang.RuntimeException: Unable to start service    com.k0gappsw.skibuddy.SBService@4051f4d0 with null: java.lang.NullPointerException
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2473)
at android.app.ActivityThread.access$2800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1127)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4385)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.k0gappsw.skibuddy.SBService.onStartCommand(SBService.java:316)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2456)
... 10 more

I have two questions: 1. Is the offending code at line 316 of SBService.java? 我有两个问题:1. SBService.java的316行处是否有违规代码? 2. The code at that line is: Bundle bundle = intent.getExtras(); 2.该行的代码是:Bundle bundle = intent.getExtras(); Any idea what could be going wrong with this? 知道这有什么问题吗? I have not seen the problem in my testing. 我在测试中没有看到问题。

My guess is the intent it is trying to grab is null hence the null pointer(obviously) 我的猜测是它试图获取的意图为null,因此为null指针(显然)

I would try this. 我会尝试的。

Bundle b = getIntent().getExtras(); 

I would also check if the activity that is calling this service is sending the intent correctly. 我还将检查调用此服务的活动是否正确发送了意图。

Don't you love mysterious stack traces that come in with random error reports! 您是否不喜欢随机错误报告附带的神秘堆栈跟踪! I'll take a stab at answering your questions: 我将竭力回答您的问题:

  1. Yes, line 316 is the offending code. 是的,第316行是违规代码。 The 'intent' must be null. “意图”必须为空。
  2. Maybe your service is being killed and recreated? 也许您的服务被取消并重新创建了? This question might provide some insight into why the intent might be null. 这个问题可能会提供一些关于为什么意图可能为空的见解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM