Debug a Android program when it running (ie, for service debugging)

First of all, compile you APK in debug mode true, you can done by

  1. change the AndroidManifest.xml, add “android:debug=’true’”, at (somewhere ^.^) application.
  2. [I use this] Use ant build, compile your APK use “ant debug”

Connect your device to PC, and try “adb devices” to find if your device connect normally.

Install your APK to device, and start the program.

Start Eclipse, if your Eclipse is install correct, the DDMS will start, you can change to DDMS view, and should see something like that (you should see your device and the program process of your debug APK)

Then go back to JAVA view, and make a Remote Debug Configuration, by ” > Debug Configurations “, then right-click on “Remote Java Application”, then click “New”. Then choose project, and be careful that, the Port is 8700 (since DDMS will forward all those Application debug port to this)

Start the Remote Debug, and when break-point is hit, the Eclipse will show you the code for step, just like the common debug at Eclipse.

61 comments to Debug a Android program when it running (ie, for service debugging)

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>