Debugging

Write App Reviews

Build your own Android App Dev Empire

Get Instant Access

Debugging an application is a skill no programmer can survive without, and fortunately it is a straightforward task to debug an Android application under Eclipse. The first step to take is to switch to the Debug Perspective in the Eclipse IDE. Remember, switching from one perspective to another takes place by using the Open Perspective submenu found under the Window menu. Starting an Android application for debugging is just as simple as running the application. Instead of selecting the application from the favorites run menu, use the favorites debug menu instead. This is the menu item with a picture of an insect (that is, a "bug"). Remember, when we set up the launch configuration, we added this configuration to both the run and the favorites debug menus.

The Debug Perspective gives us debugging capabilities similar to other development environments, including the ability to single step into, or over, method calls and peer into variables to examine their value. Breakpoints can be set by double-clicking in the left margin on the line of interest. Figure 2.20 demonstrates stepping through the Android Tip Calculator project and the resulting values showing up in the LogCat view. Note that full meal price, including tip, has not yet been displayed on the Android Emulator, because that line has not yet been reached.

Now that we've gone through a complete cycle of building an Android application and we have a good foundational understanding of using the Android development tools, we're ready to move on to digging in and Unlocking Android application development by learning about each of the fundamental aspects of building Android applications.

Figure 2.20 The Debug Perspective permits line-by-line stepping through of an Android application.

Was this article helpful?

0 0

Post a comment