Version 2.1
Copyright © 2011-2013 vogella GmbH
29.04.2013
Table of Contents
If you develop Android applications you can debug them via
Eclipse. To
enable debugging an a real Android device you need to add
the
android:debuggable="true" flag to the application segment in your
AndroidManifest.xml
file. The ADT tooling sets this flag automatically for debug builds
based on the constant
DEBUG
of the
BuildConfig
class. This class is automatically updated by the ADT.
The JVM requires that you start a Java program in Debug mode to debug it. Android allows you to turn debugging for a running application on at runtime via the Debug button in the Device view of the DDMS perspective as depicted in the following screenshot.
After turning debugging on in this view, the next time a Breakpoint is encountered Eclipse allows you to debug the process.
Android applications can be debugged similar to Java applications. See Eclipse debugging tutorial for details.
Download the zip file from http://www.vogella.com/download/androidtest/countries.zip and import the Android project from into your workspace via the
→ → → menu path.After launching the application you suppose to see a list of countries registered in the system. There is a bug in the implementation which causes the list to show empty strings.
Launch the application normally.
Realizing that their is a problem, you switch Debug mode on in the DDMS perspective.
Put a breakpoint in MainActivity.onCreate(Bundle savedInstanceState) and re-launch the activity.
Execute CountryUtils.getCountries() statement and check the value of "countries" variable. If you believe the value is incorrect, use "Step into" debug function to find the issue.
Fix the issue.
Launch the application and make sure the list of countries is shown correctly.
If you click an item in the list, application will show a toast message with the name of the country clicked. There is a bug in the applications which makes this function not working properly.
Launch the application normally.
(Try to) debug MainActivity.onListItemClick() method and fix the issue.
Launch the application and make sure correct item is show in the toast.
TRAINING | SERVICE & SUPPORT |
---|---|
The vogella company provides comprehensive training and education services from experts in the areas of Eclipse RCP, Android, Git, Java, Gradle and Spring. We offer both public and inhouse training. Whichever course you decide to take, you are guaranteed to experience what many before you refer to as “The best IT class I have ever attended”. | The vogella company offers expert consulting services, development support and coaching. Our customers range from Fortune 100 corporations to individual developers. |