I'm trying to write an application for Android and when I launch my new activity, I've set break points and found that it runs through my onCreate without any errors, but after that function returns, the debugger says there is a NullPointer Exception (NPE). The problem is, it's not in my code, it says its in ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord) line: 2268 and where the source normally would be (if it were my code) I just get "Source not found." and a button that says "Edit Source Lookup Path".
How can I set up Eclipse so I can debug this problem? I'm sure I'm doing something wrong in my code, but because the exception originates in code I can't see, I have no idea how to figure out where the problem is.
I'm using android-sdk-linux_x86-1.5_r3 and my G1 for this project.
I think my question really has more to do with Android development than using Eclipse. I'm not sure where to find the source for the code that is throwing the exception. Maybe there is a way I can debug it without having that file, but I'm not sure what it would be.
I was wondering this myself, and even though it showed the "caused by" in the LogCat, I wanted the debugger to actually break where the NullPointer exception was thrown (even though it was being caught).
Here's how:
Try running it now, and the debugger should break where it actually occurs.
Your assumption should be the NPE is caused by you, not Android. The NPE may pop at ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord) line: 2268
, but that means you passed a null pointer to something and it kept on getting passed around until performLaunchActivity
actually tried using it and crashed when it found a null pointer.
If we can see the full LogCat, particularly everything in red in the Eclipse LogCat it would help for debugging. I've turned myself inside out looking for an NPE only for someone else to find a very subtle resource initializing line out of place.
a button that says "Edit Source Lookup Path"
Hit that button and tell Eclipse where to find the source code for that method. That should help. At least you'll be able to step into it in the debugger and read something more sensible.
Usually, at least with Android, an exception triggers two separate traces. The first one is useless. The second one, noted by "Caused by exception", is the one you want.
And, even if neither stack trace has your code, we might recognize something by seeing the whole thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With