Exceptions and Stack Traces

Now back to your app’s problem. Expand the LogCat pane so that you can see what has happened. If you scroll up and down in LogCat, you should eventually find an expanse of red. This is a standard AndroidRuntime exception report.

Figure 4.3  Exception and stack trace in LogCat

Exception and stack trace in LogCat

The report tells you the top-level exception and its stack trace, then the exception that caused that exception and its stack trace, and so on and so forth until it finds an exception with no cause.

In most of the code you will write, that last exception with no cause is the interesting one. Here the exception without a cause is a java.lang.NullPointerException ...

Get Android Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.