Debugging Android: Using DDMS To Look Under The Hood
Join the DZone community and get the full member experience.
Join For FreeWhile working on an Android application recently, I ran into some problems, and was finding it difficult to work out what was actually going on in the emulator. As I'm using Appcelerator for my app development, I didn't have the luxury of using the built in Eclipse tools to find out what was wrong. Luckily for me, Google have a tool for this type of situation: the Dalvik Debug Monitor.
You can invoke the debug monitor from the tools directory of your android SDK install using the ddms command.
Here's a summary of what the tool provides:
Process View
When you first open DDMS, you will see a list of emulators on the left hand side. Each of these has a number of associated VMs running. Click on any of these VMs and you can view their information on the right hand side, including the threads and VM heap information. You can force garbage collection on any of the VMs at anytime using the trash can toolbar button.
You can also control the state of the emulator on the right hand side using the Emulator Control tab. Here you can change items such as the voice and data telephony status. This is useful if you need to simulate roaming. You can even call your emulator, providing a source phone number. This section also has local controls to help you simulate location services, passing in you location using manual coordinates, GPX or KML.
File Explorer
The file explorer was the reason I booted up the debug monitor in the first place; I needed to see if a particular file I was providing with my app was included in the final apk that I sent to the device. Not only does the file explorer allow you to browse the emulator, but you can also push and pull files from the device, as well as deleting. You can even create an SD card image for use in the emulator. When you're confused about what's getting included in your app, the file explorer is the place to go.
Device Log
The pane along the bottom presents you with the device log. Obviously this is really useful, particularly if you are not seeing enough information in your development tool.
Of course, the best way to get to know the tool is by using it. If you need to use the debug monitor, you will have your own specific use case, just as I did. I'm really impressed with the level of control and information in this tool. It's already helped me out with some very tricky problems.
Opinions expressed by DZone contributors are their own.
Comments