开发者

I've received my first Exception. Now what do I do?

I'm new to all this crazy Android/Java programming stuff. I have an app that (somehow) I managed开发者_JS百科 to figure out how to add in-app billing items to. I'm pretty sure the error is related to in-app billing, but I'm not able to reproduce the problem on any of my devices.

    NullPointerException
    in ComponentName.<init>()

    java.lang.RuntimeException: Unable to destroy activity {ca.ajwest.BeerConverter/ca.ajwest.BeerConverter.BeerConverter}: java.lang.NullPointerException
    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3035)
    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3100)
    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3216)
    at android.app.ActivityThread.access$1600(ActivityThread.java:132)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1037)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:143)
    at android.app.ActivityThread.main(ActivityThread.java:4196)
    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:839)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.NullPointerException
    at android.content.ComponentName.<init>(ComponentName.java:75)
    at android.content.Intent.<init>(Intent.java:2893)
    at ca.ajwest.BeerConverter.BillingHelper.stopService(BillingHelper.java:270)
    at ca.ajwest.BeerConverter.BeerConverter.onDestroy(BeerConverter.java:615)
    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3017)
    ... 12 more

Could somebody please direct me to some resources where I can learn more about this output or something? Does anybody have any similar experiences?

Here's the source if that helps at all.

Thanks for your help.


You should look your line 270 in BillingHelper.java and line 615 in BillingConverter. In error log, you should look for mainly two things; first, a line number which is related with your application names, second; name of the exception.

You see that

Caused by: java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:75)
at android.content.Intent.<init>(Intent.java:2893)
at ca.ajwest.BeerConverter.BillingHelper.stopService(BillingHelper.java:270)
at ca.ajwest.BeerConverter.BeerConverter.onDestroy(BeerConverter.java:615)

says, there is a null pointer exception in one of your classes. Line numbers are also noted to check. There should be a variable, which isn't initialized or already destroyed.

I hope that helps.


I've received my first Exception. Now what do I do?

You got an "Exception", while executing your code. Basically, something went wrong. Oracle's definition is "An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions."

Take a look here to learn more

In particular you got the NPE, NullPointerException

From Javadoc:

Thrown when an application attempts to use null in a case where an object is required. These include:

  • Calling the instance method of a null object.
  • Accessing or modifying the field of a null object.
  • Taking the length of null as if it were an array.
  • Accessing or modifying the slots of null as if it were an array.
  • Throwing null as if it were a Throwable value.

In other words, your program expected some object and got nothing in return.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜