How can I debug this NullPointer exception?

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.


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:

  1. Run -> Add Java Exception Breakpoint
  2. Find NullPointerException (or whatever else you might be debugging (the "Caused by" exception)
  3. Make sure Suspend On Caught Exceptions is checked. Click OK.
  4. You should see a new breakpoint in your view

Try running it now, and the debugger should break where it actually occurs.