blob: 032d6ce6f9baa6e8a218f25b16472ffc85fcb517 [file] [log] [blame]
Scott Main50e990c2012-06-21 17:14:39 -07001page.title=Debugging from Other IDEs
2parent.title=Debugging
3parent.link=index.html
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
Rich Slogar91635522014-11-07 14:47:22 -080021 <p>If you are not using Android Studio to develop, you can still take advantage of all the tools that
Scott Main50e990c2012-06-21 17:14:39 -070022 the Android SDK provides for debugging. A basic debugging environment consists of:</p>
23
24 <ul>
25 <li><a href="{@docRoot}tools/help/adb.html">ADB</a></li>
26
27 <li><a href="{@docRoot}tools/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
Rich Slogar91635522014-11-07 14:47:22 -080039 variable values. Since you are not using Android Studio, you have to manually start up the debugging
Scott Main50e990c2012-06-21 17:14:39 -070040 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
Rich Slogar91635522014-11-07 14:47:22 -080049 <li>Install and run your <code>.apk</code> file on the device or emulator. In DDMS, you should
50 see your application running under the device that you installed it to.</li>
Scott Main50e990c2012-06-21 17:14:39 -070051
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
Rich Slogar91635522014-11-07 14:47:22 -080065 for debugger" in the Development settings panel the application will run when Android Studio connects,
Scott Main50e990c2012-06-21 17:14:39 -070066 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