| Scott Main | a460a9a | 2011-02-15 15:45:24 -0800 | [diff] [blame] | 1 | page.title=Debugging from Other IDEs |
| Scott Main | 9cf2fa0 | 2011-02-15 18:26:07 -0800 | [diff] [blame] | 2 | parent.title=Debugging |
| 3 | parent.link=index.html |
| Robert Ly | ce4d229 | 2010-12-16 17:26:11 -0800 | [diff] [blame] | 4 | @jd:body |
| 5 | |
| 6 | |
| 7 | <div id="qv-wrapper"> |
| 8 | <div id="qv"> |
| 9 | <h2>In this document</h2> |
| 10 | |
| 11 | <ol> |
| 12 | <li><a href="#start-debugging">Starting a Debugging Environment</a> |
| 13 | <ul> |
| 14 | <li><a href="#debuggingPort">Configuring Your IDE to Attach to the Debugging Port</a></li> |
| 15 | </ul> |
| 16 | </li> |
| 17 | </ol> |
| 18 | </div> |
| 19 | </div> |
| 20 | |
| 21 | <p>If you are not using Eclipse to develop, you can still take advantage of all the tools that |
| 22 | the Android SDK provides for debugging. A basic debugging environment consists of:</p> |
| 23 | |
| 24 | <ul> |
| 25 | <li><a href="{@docRoot}guide/developing/tools/adb.html">ADB</a></li> |
| 26 | |
| 27 | <li><a href="{@docRoot}guide/developing/debugging/ddms.html">DDMS</a></li> |
| 28 | |
| 29 | <li>Java Debugger</li> |
| 30 | </ul> |
| 31 | |
| 32 | <p>You need to obtain a JDWP-compliant Java debugger to properly debug your application. |
| 33 | Most Java IDEs will already have one included, or you can use a command line debugger, |
| 34 | such as JDB, if you are using a simple text editor to develop applications.</p> |
| 35 | |
| 36 | <h2 id="start-debugging">Starting a debugging environment</h2> |
| 37 | <p>A Java Debugger assists you in finding problems with |
| 38 | your code by letting you set breakpoints, step through execution of your application, and examine |
| 39 | variable values. Since you are not using Eclipse, you have to manually start up the debugging |
| 40 | environment yourself by running a few tools that are provided in the Android SDK. To begin |
| 41 | debugging your application, follow these general steps:</p> |
| 42 | |
| 43 | <ol> |
| 44 | <li>Load an AVD with the Android emulator or connect a device to your computer.</li> |
| 45 | |
| 46 | <li>Start DDMS from the sdk <code>/tools</code> directory. This also starts ADB if it is |
| 47 | not already started. You should see your device appear in DDMS.</li> |
| 48 | |
| 49 | <li>Install and run your <code>.apk</code> file on the device or emulator. In DDMS, you should see your |
| 50 | application running under the device that you installed it to.</li> |
| 51 | |
| 52 | <li>Attach your debugger to the debugging port 8700, or to the specific port shown for the |
| 53 | application in DDMS.</li> |
| 54 | </ol> |
| 55 | |
| 56 | <h3 id="debuggingPort">Configuring Your IDE to Attach to the Debugging Port</h3> |
| 57 | |
| 58 | <p>DDMS assigns a specific debugging port to every virtual machine that it finds on the |
| 59 | emulator. You must either attach your IDE to that port (listed on the Info tab for that VM), or |
| 60 | you can use a default port 8700 to connect to whatever application is currently selected on the |
| 61 | list of discovered virtual machines.</p> |
| 62 | |
| 63 | <p>Your IDE should attach to your application running on the emulator, showing you its threads |
| 64 | and allowing you to suspend them, inspect their state, and set breakpoints. If you selected "Wait |
| 65 | for debugger" in the Development settings panel the application will run when Eclipse connects, |
| 66 | so you will need to set any breakpoints you want before connecting.</p> |
| 67 | |
| 68 | <p>Changing either the application being debugged or the "Wait for debugger" option causes the |
| 69 | system to kill the selected application if it is currently running. You can use this to kill your |
| 70 | application if it is in a bad state by simply going to the settings and toggling the |
| 71 | checkbox.</p> |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |