How to debug unexpected exceptions (source not found)

by Frank Weiss » Wed, 10 Feb 2010 10:38:49 GMT

Sponsored Links
 @Bob I don't think you really nailed the problem. I ran into what I think is
a similar issue. The stack trace showed the location of the throw deep in
the Android API, without a hint of a stack frame from my code. I suppose the
problem is because some of the Android code runs in different threads, so
that the exception was probably due to some data structure from my code that
the API later trips over in another thread.

I tried downloading the Android source code and adding it the the Android
project source code path. This solved the "no source found" error in the
Eclipse debugger, but unfortunately, the source code line where the
exception supposably was thrown didn't show any reasonably rational Android
code. I suppose the reason might have been that I pulled down the wrong
version of Android source.

In the end, my problems were due to not using the API correctly. In one case
it was trying to manipulate the UI from the AsyncTask.doInBackground method.
In another case it was because it was calling populate several times on a
Overlay object instead of just once after all the items had been added.

I'd still like to see an answer to the OP because it might be quite
educating to step through the Android source code. I usually figure out what
went wrong by looking at the the code that actually threw the exception and
seeing the data structure that caused it to barf.