Chapter 5. Debugging Android Applications

Unless you’re really good or really lucky, the applications you write for Android will not be perfect the first time you run them. Fortunately, Eclipse and the Android Software Development Kit provide a rich set of tools for debugging, and even some features that make it easier to write correct code. We’ll take a look at the set of available tools in this chapter, and provide some pointers to other places you can look for even more information on some of the tools.

The Tools

Throughout the development lifecycle of writing, building, and running the application, the primary tools Android developers use are:

Eclipse Java Editor

A specific text editor for Java that Android SDK has informed about the Android programming environment. The editor not only warns you about code the compiler can’t parse, but also gives you a wealth of information about what it can.

Java and Dalvik Build System

Recall that Android converts your Java application to run on the Dalvik virtual machine under Android. The Java compiler and the Dalvik translator both provide error information if they can’t build your application.

Eclipse Debugger

Eclipse provides a source-level debugger that the Android SDK connects with the running Dalvik bytecode, so you have all the debug capability you’d normally expect from a Java program running under Eclipse.

Logcat

Android also provides a general-purpose logging package that you can take advantage of to log informational or error messages from ...

Get Android Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.