Tools

The Android SDK includes a fairly extensive set of tools to help you debug your programs:

• DDMS - A graphical program that supports port forwarding (so you can set up breakpoints in your code in your IDE), screen captures on the emulator, thread and stack information, and many other features. You can also run logcat to retrieve your Log messages. See the linked topic for more information.

• logcat - Dumps a log of system messages. The messages include a stack trace when the emulator throws an error, as well as Log messages. To run logcat, see the linked topic.

• I/MemoryDealer( 763): MemoryDealer (this=0x54bda0): Creating 2621440 bytes heap at 0x438db000

I/Logger(

18

358)

: getView()

requesting

item

number

0

I/Logger(

18

358)

: getView()

requesting

item

number

1

I/Logger(

18

358)

: getView()

requesting

item

number

2

• D/ActivityManager( 763): Stopping: HistoryRecord{409dbb20 com.android.home.AllApps}

• Android Log- A logging class to print out messages to a log file on the emulator. You can read messages in real time if you run logcat on DDMS (covered next). Add a few logging method calls to your code.

To use the Log class, you just call Log.v() (verbose), Log.d() (debug), Log.i() (information), Log.w() (warning) or Log.e (error) depending on the importance you wish to assign the log message.

Log.i("MyActivity", "MyClass.getView() — Requesting item number " + position) You can use logcat to read these messages

• Traceview - Android can save a log of method calls and times to a logging file that you can view in a graphical reader called Traceview. See the linked topic for more information.

• Eclipse plugin - The ADT Plugin for Eclipse integrates a number of these tools (ADB, DDMS, logcat output, and other functionality). See the linked topic for more information.

• Debug and Test Device Settings - Android exposes several settings that expose useful information such as CPU usage and frame rate. See Debug and Test Settings on the Emulator below.

Also, see the Troubleshooting section of the doc to figure out why your application isn't appearing on the emulator, or why it's not starting.

0 0

Post a comment