Home | History | Annotate | Download | only in help
      1 page.title=Android Debug Bridge
      2 parent.title=Tools
      3 parent.link=index.html
      4 page.tags="adb"
      5 @jd:body
      6 
      7 <div id="qv-wrapper">
      8 <div id="qv">
      9   <h2>In this document</h2>
     10 <ol>
     11   <li><a href="#issuingcommands">Syntax</a></li>
     12   <li><a href="#commandsummary">Commands</a></li>
     13   <li><a href="#devicestatus">Querying for Emulator/Device Instances</a></li>
     14   <li><a href="#directingcommands">Directing Commands to a Specific Emulator/Device Instance</a></li>
     15   <li><a href="#move">Installing an Application</a></li>
     16   <li><a href="#forwardports">Forwarding Ports</a></li>
     17   <li><a href="#copyfiles">Copying Files to or from an Emulator/Device Instance</a></li>
     18   <li><a href="#shellcommands">Issuing Shell Commands</a>
     19     <ol>
     20       <li><a href="#am">Using activity manager (am)</a></li>
     21       <li><a href="#pm">Using package manager (pm)</a></li>
     22       <li><a href="#sqlite">Examining sqlite3 databases from a remote shell</a></li>
     23       <li><a href="#screenrecord">Recording a device screen</a></li>
     24       <li><a href="#monkey">UI/Application Exerciser Monkey</a></li>
     25       <li><a href="#othershellcommands">Other shell commands</a></li>
     26     </ol>
     27   </li>
     28   <li><a href="#logcat">Enabling logcat logging</a></li>
     29   <li><a href="#stopping">Stopping the adb server</a></li>
     30 </ol>
     31 
     32 </div>
     33 </div>
     34 
     35 <p>Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an
     36 emulator instance or connected Android-powered device. It is a client-server program that includes
     37 three components: </p>
     38 
     39 <ul>
     40   <li>A client, which runs on your development machine. You can invoke a client from a shell
     41 by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create
     42 adb clients. </li>
     43   <li>A server, which runs as a background process on your development machine. The server
     44 manages communication between the client and the adb daemon running on an emulator or device. </li>
     45   <li>A daemon, which runs as a background process on each emulator or device instance. </li>
     46 </ul>
     47 
     48 <p>You can find the {@code adb} tool in {@code &lt;sdk&gt;/platform-tools/}.</p>
     49 
     50 <p>When you start an adb client, the client first checks whether there is an adb server
     51 process already running. If there isn't, it starts the server process. When the server starts,
     52 it binds to local TCP port 5037 and listens for commands sent from adb clients&mdash;all adb
     53 clients use port 5037 to communicate with the adb server. </p>
     54 
     55 <p>The server then sets up connections to all running emulator/device instances. It locates emulator/device instances by scanning odd-numbered ports in the range 5555 to 5585, the range used by emulators/devices. Where the server finds an adb daemon, it sets up a connection to that port. Note that each emulator/device instance acquires a pair of sequential ports &mdash; an even-numbered port for console connections and an odd-numbered port for adb connections. For example: </p>
     56 
     57 <p style="margin-left:2em">
     58 Emulator 1, console: 5554<br/>
     59 Emulator 1, adb: 5555<br>
     60 Emulator 2, console: 5556<br>
     61 Emulator 2, adb: 5557<br>
     62 and so on...
     63 </p>
     64 
     65 <p>As shown, the emulator instance connected to adb on port 5555 is the same as the instance
     66 whose console listens on port 5554. </p>
     67 
     68 <p>Once the server has set up connections to all emulator instances, you can use adb commands to
     69 access those instances. Because the server manages connections to emulator/device
     70 instances and handles commands from multiple adb clients, you can control any emulator/device
     71 instance from any client (or from a script).</p>
     72 
     73 
     74 <p class="note"><strong>Note:</strong> When you connect a device running Android 4.2.2 or higher
     75 to your computer, the system shows a dialog asking whether to accept an RSA key that allows
     76 debugging through this computer. This security mechanism protects user devices because it ensures
     77 that USB debugging and other adb commands cannot be executed unless you're able to unlock the
     78 device and acknowledge the dialog. This requires that you have adb version 1.0.31 (available with
     79 SDK Platform-tools r16.0.1 and higher) in order to debug on a device running Android 4.2.2 or
     80 higher.</p>
     81 
     82 
     83 <h2 id="issuingcommands">Syntax</h2>
     84 
     85 <p>You can issue adb commands from a command line on your development machine or from a script.
     86 The usage is: </p>
     87 
     88 <pre class="no-pretty-print">
     89 adb [-d|-e|-s &lt;serialNumber&gt;] &lt;command&gt;
     90 </pre>
     91 
     92 <p>If there's only one emulator running or only one device connected, the adb command is
     93 sent to that device by default. If multiple emulators are running and/or multiple devices are
     94 attached, you need to use the <code>-d</code>, <code>-e</code>, or <code>-s</code>
     95 option to specify the target device to which the command should be directed. </p>
     96 
     97 
     98 
     99 <h2 id="commandsummary">Commands</h2>
    100 
    101 <p>The table below lists all of the supported adb commands and explains their meaning and usage. </p>
    102 
    103 <p class="table-caption"><strong>Table 1.</strong> Available adb commands</p>
    104 <table>
    105 <tr>
    106   <th>Category</th>
    107   <th>Command</th>
    108   <th>Description</th>
    109   <th>Comments</th>
    110 </tr>
    111 
    112 <tr>
    113 <td rowspan="3">Target Device</td>
    114 <td><code>-d</code></td>
    115 <td>Direct an adb command to the only attached USB device.</td>
    116 <td>Returns an error if more than one USB device is attached.</td>
    117 </tr>
    118 
    119 <tr>
    120 <td><code>-e</code></td>
    121 <td>Direct an adb command to the only running emulator instance.</td>
    122 <td>Returns an error if more than one emulator instance is running. </td>
    123 </tr>
    124 
    125 <tr>
    126 <td><code>-s&nbsp;&lt;serialNumber&gt;</code></td>
    127 <td>Direct an adb command a specific emulator/device instance, referred to by its adb-assigned serial number (such as "emulator-5556").</td>
    128 <td>See <a href="#directingcommands">Directing
    129 Commands to a Specific Emulator/Device Instance</a>.</td>
    130 </tr>
    131 
    132 <tr>
    133 <td rowspan="3">General</td>
    134 <td><code>devices</code></td>
    135 <td>Prints a list of all attached emulator/device instances.</td>
    136 <td>See <a href="#devicestatus">Querying for Emulator/Device Instances</a> for more information.</td>
    137 </tr>
    138 
    139 <tr>
    140 <td><code>help</code></td>
    141 <td>Prints a list of supported adb commands.</td>
    142 <td>&nbsp;</td>
    143 </tr>
    144 
    145 <tr>
    146 <td><code>version</code></td>
    147 <td>Prints the adb version number. </td>
    148 <td>&nbsp;</td>
    149 </tr>
    150 
    151 <tr>
    152 <td rowspan="3">Debug</td>
    153 <td ><code>logcat&nbsp;[option] [filter-specs]</code></td>
    154 <td>Prints log data to the screen. </td>
    155 <td>&nbsp;</td>
    156 </tr>
    157 
    158 <tr>
    159 <td><code>bugreport</code></td>
    160 <td>Prints <code>dumpsys</code>, <code>dumpstate</code>, and <code>logcat</code> data to the screen, for the purposes of bug reporting. </td>
    161 <td>&nbsp;</td>
    162 </tr>
    163 
    164 <tr>
    165 <td><code>jdwp</code></td>
    166 <td>Prints a list of available JDWP processes on a given device. </td>
    167 <td>You can use the <code>forward jdwp:&lt;pid&gt;</code> port-forwarding specification to connect to a specific JDWP process. For example: <br>
    168     <code>adb forward tcp:8000 jdwp:472</code><br>
    169     <code>jdb -attach localhost:8000</code></p>
    170  </td>
    171 </tr>
    172 
    173 <tr>
    174 <td rowspan=3">Data</td>
    175 <td><code>install&nbsp;&lt;path-to-apk&gt;</code></td>
    176 <td>Pushes an Android application (specified as a full path to an .apk file) to an emulator/device. </td>
    177 <td>&nbsp;</td>
    178 </tr>
    179 
    180 <tr>
    181 <td><code>pull&nbsp;&lt;remote&gt;&nbsp;&lt;local&gt;</code></td>
    182 <td>Copies a specified file from an emulator/device instance to your development computer. </td>
    183 <td>&nbsp;</td>
    184 </tr>
    185 
    186 <tr>
    187 <td><code>push&nbsp;&lt;local&gt;&nbsp;&lt;remote&gt;</code></td>
    188 <td>Copies a specified file from your development computer to an emulator/device instance. </td>
    189 <td>&nbsp;</td>
    190 </tr>
    191 
    192 <tr>
    193 <td rowspan="2">Ports and Networking</td>
    194 <td><code>forward&nbsp;&lt;local&gt;&nbsp;&lt;remote&gt;</code></td>
    195 <td>Forwards socket connections from a specified local port to a specified remote port on the emulator/device instance. </td>
    196 <td>Port specifications can use these schemes:
    197 <ul><li><code>tcp:&lt;portnum&gt;</code></li>
    198 <li><code>local:&lt;UNIX domain socket name&gt;</code></li>
    199 <li><code>dev:&lt;character device name&gt;</code></li>
    200 <li><code>jdwp:&lt;pid&gt;</code></li></ul>
    201 </td>
    202 </tr>
    203 
    204 <tr>
    205 <td><code>ppp&nbsp;&lt;tty&gt;&nbsp;[parm]...</code></td>
    206 <td>Run PPP over USB.
    207 <ul>
    208 <li><code>&lt;tty&gt;</code> &mdash; the tty for PPP stream. For example <code>dev:/dev/omap_csmi_ttyl</code>. </li>
    209 <li><code>[parm]... </code> &mdash; zero or more PPP/PPPD options, such as <code>defaultroute</code>, <code>local</code>, <code>notty</code>, etc.</li></ul>
    210 
    211 <p>Note that you should not automatically start a PPP connection. </p></td>
    212 <td></td>
    213 </tr>
    214 
    215 <tr>
    216 <td rowspan="3">Scripting</td>
    217 <td><code>get-serialno</code></td>
    218 <td>Prints the adb instance serial number string.</td>
    219 <td rowspan="2">See <a href="#devicestatus">Querying for Emulator/Device Instances</a> for more information. </td>
    220 </tr>
    221 
    222 <tr>
    223 <td><code>get-state</code></td>
    224 <td>Prints the adb state of an emulator/device instance.</td>
    225 </td>
    226 </tr>
    227 
    228 <tr>
    229 <td><code>wait-for-device</code></td>
    230 <td>Blocks execution until the device is online &mdash; that is, until the instance state is <code>device</code>.</td>
    231 <td>You can prepend this command to other adb commands, in which case adb will wait until the emulator/device instance is connected before issuing the other commands. Here's an example:
    232 <pre class="no-pretty-print">adb wait-for-device shell getprop</pre>
    233 
    234 Note that this command does <em>not</em> cause adb to wait until the entire system is fully booted. For that reason, you should not prepend it to other commands that require a fully booted system. As an example, the <code>install</code> requires the Android package manager, which is available only after the system is fully booted. A command such as
    235 
    236 <pre class="no-pretty-print">adb wait-for-device install &lt;app&gt;.apk</pre>
    237 
    238 would issue the <code>install</code> command as soon as the emulator or device instance connected to the adb server, but before the Android system was fully booted, so it would result in an error. </td>
    239 </tr>
    240 
    241 
    242 
    243 <tr>
    244 <td rowspan="2">Server</td>
    245 <td><code>start-server</code></td>
    246 <td>Checks whether the adb server process is running and starts it, if not.</td>
    247 <td>&nbsp;</td>
    248 </tr>
    249 
    250 <tr>
    251 <td><code>kill-server</code></td>
    252 <td>Terminates the adb server process.</td>
    253 <td>&nbsp;</td>
    254 </tr>
    255 
    256 
    257 
    258 <tr>
    259 <td rowspan="2">Shell</td>
    260 <td><code>shell</code></td>
    261 <td>Starts a remote shell in the target emulator/device instance.</td>
    262 <td rowspan="2">See <a href="#shellcommands">Issuing Shell Commands</a> for more information. </td>
    263 </tr>
    264 
    265 <tr>
    266 <td><code>shell&nbsp;[shellCommand]</code></td>
    267 <td>Issues a shell command in the target emulator/device instance and then exits the remote shell.</td>
    268 </tr>
    269 
    270 </table>
    271 
    272 
    273 
    274 
    275 
    276 
    277 
    278 
    279 
    280 
    281 <h2 id="devicestatus">Querying for Emulator/Device Instances</h2>
    282 
    283 <p>Before issuing adb commands, it is helpful to know what emulator/device instances are connected to the adb server. You can generate a list of attached emulators/devices using the <code>devices</code> command: </p>
    284 
    285   <pre class="no-pretty-print">adb devices</pre>
    286 
    287 <p>In response, adb prints this status information for each instance:</p>
    288 
    289 <ul>
    290   <li>Serial number &mdash; A string created by adb to uniquely identify an emulator/device instance by its
    291     console port number. The format of the serial number is <code>&lt;type&gt;-&lt;consolePort&gt;</code>.
    292     Here's an example serial number: <code>emulator-5554</code></li>
    293   <li>State &mdash; The connection state of the instance may be one of the following:
    294     <ul>
    295       <li><code>offline</code> &mdash; the instance is not connected to adb or is not responding.</li>
    296       <li><code>device</code> &mdash; the instance is now connected to the adb server. Note that this state does not
    297         imply that the Android system is fully booted and operational, since the instance connects to adb
    298         while the system is still booting. However, after boot-up, this is the normal operational state of
    299         an emulator/device instance.</li>
    300       <li><code>no device</code> &mdash; there is no emulator/device connected.
    301     </ul>
    302   </li>
    303 </ul>
    304 
    305 <p>The output for each instance is formatted like this: </p>
    306 
    307   <pre class="no-pretty-print">[serialNumber] [state]</pre>
    308 
    309 <p>Here's an example showing the <code>devices</code> command and its output:</p>
    310 
    311   <pre class="no-pretty-print">adb devices
    312 List of devices attached
    313 emulator-5554&nbsp;&nbsp;device
    314 emulator-5556&nbsp;&nbsp;device
    315 emulator-5558&nbsp;&nbsp;device</pre>
    316 
    317 
    318 
    319 
    320 
    321 
    322 <h2 id="directingcommands">Directing Commands to a Specific Emulator/Device Instance</h2>
    323 
    324 <p>If multiple emulator/device instances are running, you must specify a target instance
    325 when issuing adb commands. To do so, use the <code>-s</code> option in the commands. The usage
    326 for the <code>-s</code> option is:</p>
    327 
    328 <pre class="no-pretty-print">adb -s &lt;serialNumber&gt; &lt;command&gt; </pre>
    329 
    330 <p>As shown, you specify the target instance for a command using its adb-assigned serial number.
    331 You can use the <code>devices</code> command to obtain the serial numbers of running
    332 emulator/device instances. For example: </p>
    333 
    334 <pre class="no-pretty-print">adb -s emulator-5556 install helloWorld.apk</pre>
    335 
    336 <p>Note that, if you issue a command without specifying a target emulator/device instance
    337 while multiple devices are available, adb generates an error.
    338 
    339 <p>If you have multiple devices available (hardware or emulated), but only one is an emulator,
    340 simply use the {@code -e} option to send commands to the emulator. Likewise if there's multiple
    341 devices but only one hardware device attached, use the {@code -d} option to send commands to
    342 the hardware device.
    343 
    344 
    345 
    346 
    347 <h2 id="move">Installing an Application</h2>
    348 <p>You can use adb to copy an application from your development computer and install it on an emulator/device instance. To do so, use the <code>install</code> command. With the command, you must specify the path to the .apk file that you want to install:</p>
    349 
    350 <pre class="no-pretty-print">adb install &lt;path_to_apk&gt;</pre>
    351 
    352 <p>For more information about how to create an .apk file that you can install on an emulator/device
    353 instance, see <a href="{@docRoot}tools/building/index.html">Building and Running</a></p>
    354 
    355 <p>Note that, if you are using the Eclipse IDE and have the ADT plugin installed, you do not need to use adb (or aapt) directly to install your application on the emulator/device. Instead, the ADT plugin handles the packaging and installation of the application for you. </p>
    356 
    357 
    358 
    359 
    360 
    361 
    362 <h2 id="forwardports">Forwarding Ports</h2>
    363 
    364     <p>You can use the <code>forward</code> command to set up arbitrary port forwarding &mdash; forwarding of requests on a specific host port to a different port on an emulator/device instance. Here's how you would set up forwarding of host port 6100 to emulator/device port 7100:</p>
    365 <pre class="no-pretty-print">adb forward tcp:6100 tcp:7100</pre>
    366     <p>You can also use adb to set up forwarding to named abstract UNIX domain sockets, as illustrated here:</p>
    367 <pre class="no-pretty-print">adb forward tcp:6100 local:logd </pre>
    368 
    369 
    370 
    371 
    372 
    373 <h2 id="copyfiles">Copying Files to or from an Emulator/Device Instance</h2>
    374 
    375 <p>You can use the adb commands <code>pull</code> and <code>push</code> to copy files to
    376 and from an emulator/device instance. Unlike the <code>install</code> command,
    377 which only copies an APK file to a specific location, the <code>pull</code> and <code>push</code>
    378 commands let you copy arbitrary directories and files to any location in an
    379 emulator/device instance. </p>
    380 
    381 <p>To copy a file or directory (and its sub-directories) <em>from</em> the emulator or device, use</p>
    382 <pre class="no-pretty-print">adb pull &lt;remote&gt; &lt;local&gt;</pre>
    383 
    384 <p>To copy a file or directory (and its sub-directories) <em>to</em> the emulator or device, use</p>
    385     <pre class="no-pretty-print">adb push &lt;local&gt; &lt;remote&gt;</pre>
    386 
    387 <p>In the commands, <code>&lt;local&gt;</code> and <code>&lt;remote&gt;</code> refer to the
    388 paths to the target files/directory on your development machine (local) and on the
    389 emulator/device instance (remote). For example: </p>
    390 <pre class="no-pretty-print">adb push foo.txt /sdcard/foo.txt</pre>
    391 
    392 
    393 
    394 
    395 
    396 
    397 
    398 
    399 
    400 <h2 id="shellcommands">Issuing Shell Commands</h2>
    401 
    402 <p>Adb provides a Unix shell that you can use to run a variety of commands on an emulator
    403 or connected device. The command binaries are stored in the file system of the emulator or device,
    404 at <code>/system/bin/...</code>
    405 
    406 <p>Two of the most common command tools are <a href="#am">activity manager</a> ({@code am}) and
    407 <a href="#pm">package manager</a> ({@code pm}).</p>
    408 
    409 <p>You can use the <code>shell</code> command to issue commands, with or without entering
    410 the adb remote shell on the emulator/device. To issue a single command without entering a
    411 remote shell, use the <code>shell</code> command like this: </p>
    412 
    413   <pre class="no-pretty-print">adb [-d|-e|-s &lt;serialNumber&gt;] shell &lt;shell_command&gt;</pre>
    414 
    415 <p>Or enter a remote shell on an emulator/device like this:</p>
    416 
    417   <pre class="no-pretty-print">adb [-d|-e|-s &lt;serialNumber&gt;] shell</pre>
    418 
    419 <p>When you are ready to exit the remote shell, press CTRL+D or type
    420 <code>exit</code>. </p>
    421 
    422 
    423 
    424 
    425 
    426 <h3 id="am">Using activity manager (am)</h3>
    427 
    428 <p>Within an adb shell, you can issue commands with the activity manager ({@code am}) tool to
    429 perform various system actions, such as start an activity, force-stop a process,
    430 broadcast an intent, modify the device screen properties, and more. While in a shell,
    431 the syntax is:</p>
    432 <pre class="no-pretty-print">
    433 am &lt;command>
    434 </pre>
    435 
    436 <p>You can also issue an activity manager command directly from adb
    437 without entering a remote shell. For example:</p>
    438 <pre class="no-pretty-print">
    439 adb shell am start -a android.intent.action.VIEW
    440 </pre>
    441 
    442 
    443 <p class="table-caption"><strong>Table 2.</strong> Available activity manager commands</p>
    444 <table>
    445 <tr>
    446   <th>Command</th>
    447   <th>Description</th>
    448 </tr>
    449 
    450 <tr>
    451 <td><code>
    452 start [options] &lt;INTENT>
    453 </code></td>
    454 <td>Start an {@link android.app.Activity} specified by {@code &lt;INTENT>}. <p>See the
    455 <a href="#IntentSpec">Specification for &lt;INTENT> arguments</a>.
    456 <p>Options are:
    457 <ul>
    458     <li>{@code -D}: Enable debugging.
    459     <li>{@code -W}: Wait for launch to complete.
    460     <li>{@code --start-profiler &lt;FILE>}: Start profiler and send results to {@code &lt;FILE>}.
    461     <li>{@code -P &lt;FILE>}: Like <code>--start-profiler</code>,
    462         but profiling stops when the app goes idle.
    463     <li>{@code -R}: Repeat the activity launch {@code &lt;COUNT>} times.  Prior to each repeat,
    464         the top activity will be finished.
    465     <li>{@code -S}: Force stop the target app before starting the activity.
    466     <li>{@code --opengl-trace}: Enable tracing of OpenGL functions.
    467     <li>{@code --user &lt;USER_ID> | current}: Specify which user to run as; if not
    468         specified, then run as the current user.
    469 </ul>
    470 </td>
    471 </tr>
    472 
    473 <tr>
    474 <td><code>
    475 startservice [options] &lt;INTENT>
    476 </code></td>
    477 <td>Start the {@link android.app.Service} specified by {@code &lt;INTENT>}. <p>See the
    478 <a href="#IntentSpec">Specification for &lt;INTENT> arguments</a>.
    479 <p>Options are:
    480 <ul>
    481     <li>{@code --user &lt;USER_ID> | current}: Specify which user to run as; if not
    482         specified, then run as the current user.
    483 </ul>
    484 </td>
    485 </tr>
    486 
    487 <tr>
    488 <td><code>
    489 force-stop &lt;PACKAGE>
    490 </code></td>
    491 <td>Force stop everything associated with {@code &lt;PACKAGE>} (the app's package name).
    492 </td>
    493 </tr>
    494 
    495 <tr>
    496 <td><code>
    497 kill  [options] &lt;PACKAGE>
    498 </code></td>
    499 <td> Kill all processes associated with {@code &lt;PACKAGE>}
    500   (the app's package name).  This command kills only
    501   processes that are safe to kill and that will not impact the user
    502   experience.
    503   <p>Options are:
    504   <ul>
    505       <li>{@code --user &lt;USER_ID> | all | current}: Specify user whose processes to kill;
    506         all users if not specified.
    507   </ul>
    508 </td>
    509 </tr>
    510 
    511 <tr>
    512 <td><code>
    513 kill-all
    514 </code></td>
    515 <td>Kill all background processes.
    516 </td>
    517 </tr>
    518 
    519 <tr>
    520 <td><code>
    521 broadcast [options] &lt;INTENT>
    522 </code></td>
    523 <td>Issue a broadcast intent. <p>See the
    524 <a href="#IntentSpec">Specification for &lt;INTENT> arguments</a>.
    525 <p>Options are:
    526 <ul>
    527     <li>{@code [--user &lt;USER_ID> | all | current]}: Specify which user to send to; if not
    528         specified then send to all users.
    529 </ul>
    530 </td>
    531 </tr>
    532 
    533 <tr>
    534 <td><code>
    535 instrument [options] &lt;COMPONENT>
    536 </code></td>
    537 <td>Start monitoring with an {@link android.app.Instrumentation} instance.
    538   Typically the target {@code &lt;COMPONENT>}
    539   is the form {@code &lt;TEST_PACKAGE>/&lt;RUNNER_CLASS>}.  <p>Options are:
    540 <ul>
    541     <li>{@code -r}: Print raw results (otherwise decode
    542         {@code &lt;REPORT_KEY_STREAMRESULT>}).  Use with
    543         {@code [-e perf true]} to generate raw output for performance measurements.
    544 
    545     <li>{@code -e &lt;NAME> &lt;VALUE>}: Set argument {@code &lt;NAME>} to {@code &lt;VALUE>}.
    546         For test runners a common form is {@code
    547         -e &lt;testrunner_flag> &lt;value>[,&lt;value>...]}.
    548 
    549     <li>{@code -p &lt;FILE>}: Write profiling data to {@code &lt;FILE>}.
    550 
    551     <li>{@code -w}: Wait for instrumentation to finish before returning.  Required for
    552         test runners.
    553 
    554     <li>{@code --no-window-animation}: Turn off window animations while running.
    555     <li>{@code --user &lt;USER_ID> | current}: Specify which user instrumentation runs in;
    556         current user if not specified.
    557 </ul>
    558 
    559 </td>
    560 </tr>
    561 
    562 <tr>
    563 <td><code>
    564 profile start &lt;PROCESS> &lt;FILE>
    565 </code></td>
    566 <td>Start profiler on {@code &lt;PROCESS>}, write results to {@code &lt;FILE>}.
    567 </td>
    568 </tr>
    569 
    570 <tr>
    571 <td><code>
    572 profile stop &lt;PROCESS>
    573 </code></td>
    574 <td>Stop profiler on {@code &lt;PROCESS>}.
    575 </td>
    576 </tr>
    577 
    578 <tr>
    579 <td style="white-space:nowrap"><code>
    580 dumpheap [options] &lt;PROCESS> &lt;FILE>
    581 </code></td>
    582 <td>Dump the heap of {@code &lt;PROCESS>}, write to {@code &lt;FILE>}. <p>Options are:
    583 <ul>
    584     <li>{@code --user [&lt;USER_ID>|current]}: When supplying a process name,
    585         specify user of process to dump; uses current user if not specified.
    586     <li>{@code -n}: Dump native heap instead of managed heap.
    587 </ul>
    588 </td>
    589 </tr>
    590 
    591 <tr>
    592 <td><code>
    593 set-debug-app [options] &lt;PACKAGE>
    594 </code></td>
    595 <td>Set application {@code &lt;PACKAGE>} to debug.  <p>Options are:
    596 <ul>
    597     <li>{@code -w}: Wait for debugger when application starts.
    598     <li>{@code --persistent}: Retain this value.
    599 </ul>
    600 </td>
    601 </tr>
    602 
    603 <tr>
    604 <td><code>
    605 clear-debug-app
    606 </code></td>
    607 <td>Clear the package previous set for debugging with {@code set-debug-app}.
    608 </td>
    609 </tr>
    610 
    611 <tr>
    612 <td><code>
    613 monitor [options]
    614 </code></td>
    615 <td>Start monitoring for crashes or ANRs.  <p>Options are:
    616 <ul>
    617     <li>{@code --gdb}: Start gdbserv on the given port at crash/ANR.
    618 </ul>
    619 </td>
    620 </tr>
    621 
    622 <tr>
    623 <td><code>
    624 screen-compat [on|off] &lt;PACKAGE>
    625 </code></td>
    626 <td>Control <a href="{@docRoot}guide/practices/screen-compat-mode.html">screen
    627 compatibility</a> mode of {@code &lt;PACKAGE>}.</p>
    628 </td>
    629 </tr>
    630 
    631 <tr>
    632 <td><code>
    633 display-size [reset|&lt;WxH>]
    634 </code></td>
    635 <td>Override emulator/device display size.
    636 This command is helpful for testing your app across different screen sizes by mimicking a small
    637 screen resolution using a device with a large screen, and vice versa.
    638 <p>Example:<br><code>am display-size 1280x800</code>
    639 </td>
    640 </tr>
    641 
    642 <tr>
    643 <td><code>
    644 display-density &lt;dpi>
    645 </code></td>
    646 <td>Override emulator/device display density.
    647 This command is helpful for testing your app across different screen densities on high-density
    648 screen environment using a low density screen, and vice versa.
    649 <p>Example:<br><code>am display-density 480</code>
    650 </td>
    651 </tr>
    652 
    653 <tr>
    654 <td><code>
    655 to-uri &lt;INTENT>
    656 </code></td>
    657 <td>Print the given intent specification as a URI. <p>See the
    658 <a href="#IntentSpec">Specification for &lt;INTENT> arguments</a>.
    659 </td>
    660 </tr>
    661 
    662 <tr>
    663 <td><code>
    664 to-intent-uri &lt;INTENT>
    665 </code></td>
    666 <td>Print the given intent specification as an {@code intent:} URI. <p>See the
    667 <a href="#IntentSpec">Specification for &lt;INTENT> arguments</a>.
    668 </td>
    669 </tr>
    670 </table>
    671 
    672 
    673 
    674 
    675 
    676 <h4 id="IntentSpec">
    677   <a href="" class="expandable" onclick="toggleExpandable(this,'.intents');
    678 return false">Specification for &lt;INTENT> arguments</a></h4>
    679 
    680 <div class="intents" style="display:none">
    681 
    682 <p>For activity manager commands that take a {@code &lt;INTENT>} argument, you can
    683 specify the intent with the following options:</p>
    684 
    685 <dl>
    686   <dt>{@code -a &lt;ACTION>}</dt>
    687       <dd>Specify the intent action, such as "android.intent.action.VIEW".
    688       You can declare this only once.
    689 
    690   <dt>{@code -d &lt;DATA_URI>}</dt>
    691       <dd>Specify the intent data URI, such as "content://contacts/people/1".
    692       You can declare this only once.
    693 
    694   <dt>{@code -t &lt;MIME_TYPE>}</dt>
    695       <dd>Specify the intent MIME type, such as "image/png".
    696       You can declare this only once.
    697 
    698   <dt>{@code -c &lt;CATEGORY>}</dt>
    699       <dd>Specify an intent category, such as "android.intent.category.APP_CONTACTS".
    700 
    701   <dt>{@code -n &lt;COMPONENT>}</dt>
    702       <dd>Specify the component name with package name prefix to create an explicit intent, such
    703       as "com.example.app/.ExampleActivity".
    704 
    705   <dt>{@code -f &lt;FLAGS>}</dt>
    706       <dd>Add flags to the intent, as supported by {@link
    707         android.content.Intent#setFlags setFlags()}.
    708 
    709   <dt>{@code --esn &lt;EXTRA_KEY>}</dt>
    710       <dd>Add a null extra. This option is not supported for URI intents.
    711 
    712   <dt>{@code -e|--es &lt;EXTRA_KEY> &lt;EXTRA_STRING_VALUE>}</dt>
    713       <dd>Add string data as a key-value pair.
    714 
    715   <dt>{@code --ez &lt;EXTRA_KEY> &lt;EXTRA_BOOLEAN_VALUE>}</dt>
    716       <dd>Add boolean data as a key-value pair.
    717 
    718   <dt>{@code --ei &lt;EXTRA_KEY> &lt;EXTRA_INT_VALUE>}</dt>
    719       <dd>Add integer data as a key-value pair.
    720 
    721   <dt>{@code --el &lt;EXTRA_KEY> &lt;EXTRA_LONG_VALUE>}</dt>
    722       <dd>Add long data as a key-value pair.
    723 
    724   <dt>{@code --ef &lt;EXTRA_KEY> &lt;EXTRA_FLOAT_VALUE>}</dt>
    725       <dd>Add float data as a key-value pair.
    726 
    727   <dt>{@code --eu &lt;EXTRA_KEY> &lt;EXTRA_URI_VALUE>}</dt>
    728       <dd>Add URI data as a key-value pair.
    729 
    730   <dt>{@code --ecn &lt;EXTRA_KEY> &lt;EXTRA_COMPONENT_NAME_VALUE>}</dt>
    731       <dd>Add a component name, which is converted and passed as
    732       a {@link android.content.ComponentName} object.
    733 
    734   <dt>{@code --eia &lt;EXTRA_KEY> &lt;EXTRA_INT_VALUE>[,&lt;EXTRA_INT_VALUE...]}</dt>
    735       <dd>Add an array of integers.
    736 
    737   <dt>{@code --ela &lt;EXTRA_KEY> &lt;EXTRA_LONG_VALUE>[,&lt;EXTRA_LONG_VALUE...]}</dt>
    738       <dd>Add an array of longs.
    739 
    740   <dt>{@code --efa &lt;EXTRA_KEY> &lt;EXTRA_FLOAT_VALUE>[,&lt;EXTRA_FLOAT_VALUE...]}</dt>
    741       <dd>Add an array of floats.
    742 
    743   <dt>{@code --grant-read-uri-permission}</dt>
    744       <dd>Include the flag {@link android.content.Intent#FLAG_GRANT_READ_URI_PERMISSION}.
    745 
    746   <dt>{@code --grant-write-uri-permission}</dt>
    747       <dd>Include the flag {@link android.content.Intent#FLAG_GRANT_WRITE_URI_PERMISSION}.
    748 
    749   <dt>{@code --debug-log-resolution}</dt>
    750       <dd>Include the flag {@link android.content.Intent#FLAG_DEBUG_LOG_RESOLUTION}.
    751 
    752   <dt>{@code --exclude-stopped-packages}</dt>
    753       <dd>Include the flag {@link android.content.Intent#FLAG_EXCLUDE_STOPPED_PACKAGES}.
    754 
    755   <dt>{@code --include-stopped-packages}</dt>
    756       <dd>Include the flag {@link android.content.Intent#FLAG_INCLUDE_STOPPED_PACKAGES}.
    757 
    758   <dt>{@code --activity-brought-to-front}</dt>
    759       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_BROUGHT_TO_FRONT}.
    760 
    761   <dt>{@code --activity-clear-top}</dt>
    762       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_CLEAR_TOP}.
    763 
    764   <dt>{@code --activity-clear-when-task-reset}</dt>
    765       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET}.
    766 
    767   <dt>{@code --activity-exclude-from-recents}</dt>
    768       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS}.
    769 
    770   <dt>{@code --activity-launched-from-history}</dt>
    771       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY}.
    772 
    773   <dt>{@code --activity-multiple-task}</dt>
    774       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_MULTIPLE_TASK}.
    775 
    776   <dt>{@code --activity-no-animation}</dt>
    777       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_NO_ANIMATION}.
    778 
    779   <dt>{@code --activity-no-history}</dt>
    780       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_NO_HISTORY}.
    781 
    782   <dt>{@code --activity-no-user-action}</dt>
    783       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_NO_USER_ACTION}.
    784 
    785   <dt>{@code --activity-previous-is-top}</dt>
    786       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_PREVIOUS_IS_TOP}.
    787 
    788   <dt>{@code --activity-reorder-to-front}</dt>
    789       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_REORDER_TO_FRONT}.
    790 
    791   <dt>{@code --activity-reset-task-if-needed}</dt>
    792       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_RESET_TASK_IF_NEEDED}.
    793 
    794   <dt>{@code --activity-single-top}</dt>
    795       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_SINGLE_TOP}.
    796 
    797   <dt>{@code --activity-clear-task}</dt>
    798       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_CLEAR_TASK}.
    799 
    800   <dt>{@code --activity-task-on-home}</dt>
    801       <dd>Include the flag {@link android.content.Intent#FLAG_ACTIVITY_TASK_ON_HOME}.
    802 
    803   <dt>{@code --receiver-registered-only}</dt>
    804       <dd>Include the flag {@link android.content.Intent#FLAG_RECEIVER_REGISTERED_ONLY}.
    805 
    806   <dt>{@code --receiver-replace-pending}</dt>
    807       <dd>Include the flag {@link android.content.Intent#FLAG_RECEIVER_REPLACE_PENDING}.
    808 
    809   <dt>{@code --selector}</dt>
    810       <dd>Requires the use of {@code -d} and {@code -t} options to set the intent data and type.
    811 
    812   <dt>{@code &lt;URI> &lt;COMPONENT> &lt;PACKAGE>}</dt>
    813       <dd>You can directly specify a URI, package name, and component name when not qualified
    814       by one of the above options. When an argument is unqualified, the tool assumes the argument
    815       is a URI if it contains a ":" (colon); it assumes the argument is a component name if it
    816       contains a "/" (forward-slash); otherwise it assumes the argument is a package name.
    817 
    818 </dl>
    819 </div><!-- end 'intents' -->
    820 <script>
    821   $(window).hashchange( function(){
    822     if ((location.hash == "#IntentSpec") && !($("#IntentSpec a").hasClass("expanded"))) {
    823       $("#IntentSpec a").click();
    824     }
    825   });
    826 </script>
    827 
    828 
    829 
    830 <h3 id="pm">Using package manager (pm)</h3>
    831 
    832 <p>Within an adb shell, you can issue commands with the package manager ({@code pm}) tool to
    833 perform actions and queries on application packages installed on the device. While in a shell,
    834 the syntax is:</p>
    835 <pre class="no-pretty-print">
    836 pm &lt;command>
    837 </pre>
    838 
    839 <p>You can also issue a package manager command directly from adb
    840 without entering a remote shell. For example:</p>
    841 <pre class="no-pretty-print">
    842 adb shell pm uninstall com.example.MyApp
    843 </pre>
    844 
    845 <p class="table-caption"><strong>Table 3.</strong> Available package manager commands.</p>
    846 <table>
    847 <tr>
    848   <th>Command</th>
    849   <th>Description</th>
    850 </tr>
    851 
    852 <tr>
    853 <td><code>
    854 list packages [options] &lt;FILTER>
    855 </code></td>
    856 <td>Prints all packages, optionally only
    857   those whose package name contains the text in {@code &lt;FILTER>}.  <p>Options:
    858 <ul>
    859     <li>{@code -f}: See their associated file.
    860     <li>{@code -d}: Filter to only show disabled packages.
    861     <li>{@code -e}: Filter to only show enabled packages.
    862     <li>{@code -s}: Filter to only show system packages.
    863     <li>{@code -3}: Filter to only show third party packages.
    864     <li>{@code -i}: See the installer for the packages.
    865     <li>{@code -u}: Also include uninstalled packages.
    866     <li>{@code --user &lt;USER_ID>}: The user space to query.
    867 </ul>
    868 </td>
    869 </tr>
    870 
    871 <tr>
    872 <td><code>
    873 list permission-groups
    874 </code></td>
    875 <td>Prints all known permission groups.
    876 </td>
    877 </tr>
    878 
    879 <tr>
    880 <td><code>
    881 list permissions [options] &lt;GROUP>
    882 </code></td>
    883 <td>Prints all known permissions, optionally only
    884   those in {@code &lt;GROUP>}.  <p>Options:
    885 <ul>
    886     <li>{@code -g}: Organize by group.
    887     <li>{@code -f}: Print all information.
    888     <li>{@code -s}: Short summary.
    889     <li>{@code -d}: Only list dangerous permissions.
    890     <li>{@code -u}: List only the permissions users will see.
    891 </ul>
    892 </td>
    893 </tr>
    894 
    895 <tr>
    896 <td><code>
    897 list instrumentation
    898 </code></td>
    899 <td>List all test packages.  <p>Options:
    900   <ul>
    901     <li>{@code -f}: List the APK file for the test package.
    902     <li>{@code &lt;TARGET_PACKAGE>}: List test packages for only this app.
    903   </ul>
    904 </td>
    905 </tr>
    906 
    907 <tr>
    908 <td><code>
    909 list features
    910 </code></td>
    911 <td>Prints all features of the system.
    912 </td>
    913 </tr>
    914 
    915 <tr>
    916 <td><code>
    917 list libraries
    918 </code></td>
    919 <td>Prints all the libraries supported by the current device.
    920 </td>
    921 </tr>
    922 
    923 <tr>
    924 <td><code>
    925 list users
    926 </code></td>
    927 <td>Prints all users on the system.
    928 </td>
    929 </tr>
    930 
    931 <tr>
    932 <td><code>
    933 path &lt;PACKAGE>
    934 </code></td>
    935 <td>Print the path to the APK of the given {@code &lt;PACKAGE>}.
    936 </td>
    937 </tr>
    938 
    939 <tr>
    940 <td><code>
    941 install [options]  &lt;PATH>
    942 </code></td>
    943 <td>Installs a package (specified by {@code &lt;PATH>}) to the system.  <p>Options:
    944   <ul>
    945     <li>{@code -l}: Install the package with forward lock.
    946     <li>{@code -r}: Reinstall an exisiting app, keeping its data.
    947     <li>{@code -t}: Allow test APKs to be installed.
    948     <li>{@code -i &lt;INSTALLER_PACKAGE_NAME>}: Specify the installer package name.
    949     <li>{@code -s}: Install package on the shared mass storage (such as sdcard).
    950     <li>{@code -f}: Install package on the internal system memory.
    951     <li>{@code -d}: Allow version code downgrade.
    952   </ul>
    953 </td>
    954 </tr>
    955 
    956 <tr>
    957 <td><code>
    958 uninstall [options] &lt;PACKAGE>
    959 </code></td>
    960 <td>Removes a package from the system. <p>Options:
    961   <ul>
    962     <li>{@code -k}: Keep the data and cache directories around after package removal.
    963   </ul>
    964 </td>
    965 </tr>
    966 
    967 <tr>
    968 <td><code>
    969 clear &lt;PACKAGE>
    970 </code></td>
    971 <td>Deletes all data associated with a package.
    972 </td>
    973 </tr>
    974 
    975 <tr>
    976 <td><code>
    977 enable &lt;PACKAGE_OR_COMPONENT>
    978 </code></td>
    979 <td>Enable the given package or component (written as "package/class").
    980 </td>
    981 </tr>
    982 
    983 <tr>
    984 <td><code>
    985 disable &lt;PACKAGE_OR_COMPONENT>
    986 </code></td>
    987 <td>Disable the given package or component (written as "package/class").
    988 </td>
    989 </tr>
    990 
    991 <tr>
    992 <td style="white-space:nowrap"><code>
    993 disable-user [options] &lt;PACKAGE_OR_COMPONENT>
    994 </code></td>
    995 <td><p>Options:
    996   <ul>
    997     <li>{@code --user &lt;USER_ID>}: The user to disable.
    998   </ul>
    999 </td>
   1000 </tr>
   1001 
   1002 <tr>
   1003 <td><code>
   1004 grant &lt;PACKAGE_PERMISSION>
   1005 </code></td>
   1006 <td>Grant permissions
   1007   to applications.  Only optional permissions the application has
   1008   declared can be granted.
   1009 </td>
   1010 </tr>
   1011 
   1012 <tr>
   1013 <td><code>
   1014 revoke &lt;PACKAGE_PERMISSION>
   1015 </code></td>
   1016 <td>Revoke permissions
   1017   to applications.  Only optional permissions the application has
   1018   declared can be revoked.
   1019 </td>
   1020 </tr>
   1021 
   1022 <tr>
   1023 <td><code>
   1024 set-install-location &lt;LOCATION>
   1025 </code></td>
   1026 <td>Changes the default install location. Location values:
   1027 <ul>
   1028     <li>{@code 0}: Auto&mdash;Let system decide the best location.
   1029     <li>{@code 1}: Internal&mdash;install on internal device storage.
   1030     <li>{@code 2}: External&mdash;install on external media.
   1031 </ul>
   1032 <p class="note"><strong>Note:</strong> This is only intended for debugging; using this can cause
   1033   applications to break and other undesireable behavior.</p>
   1034 </td>
   1035 </tr>
   1036 
   1037 <tr>
   1038 <td><code>
   1039 get-install-location
   1040 </code></td>
   1041 <td>Returns the current install location. Return values:
   1042 <ul>
   1043   <li>{@code 0 [auto]}: Lets system decide the best location
   1044   <li>{@code 1 [internal]}: Installs on internal device storage
   1045   <li>{@code 2 [external]}: Installs on external media
   1046 </ul>
   1047 </td>
   1048 </tr>
   1049 
   1050 <tr>
   1051 <td><code>
   1052 set-permission-enforced &lt;PERMISSION> [true|false]
   1053 </code></td>
   1054 <td>Specifies whether the given permission should be enforced.
   1055 </td>
   1056 </tr>
   1057 
   1058 <tr>
   1059 <td><code>
   1060 trim-caches &lt;DESIRED_FREE_SPACE>
   1061 </code></td>
   1062 <td>Trim cache files to reach the given free space.
   1063 </td>
   1064 </tr>
   1065 
   1066 <tr>
   1067 <td><code>
   1068 create-user &lt;USER_NAME>
   1069 </code></td>
   1070 <td>Create a new user with the given {@code &lt;USER_NAME>},
   1071   printing the new user identifier of the user.
   1072 </td>
   1073 </tr>
   1074 
   1075 <tr>
   1076 <td><code>
   1077 remove-user &lt;USER_ID>
   1078 </code></td>
   1079 <td>Remove the user with the given {@code &lt;USER_IDENTIFIER>},
   1080   deleting all data associated with that user
   1081 </td>
   1082 </tr>
   1083 
   1084 <tr>
   1085 <td><code>
   1086 get-max-users
   1087 </code></td>
   1088 <td>Prints the maximum number of users supported by the device.
   1089 </td>
   1090 </tr>
   1091 
   1092 </table>
   1093 
   1094 
   1095 
   1096 
   1097 
   1098 
   1099 
   1100 <h3 id="sqlite">Examining sqlite3 databases from a remote shell</h3>
   1101 
   1102 <p>From an adb remote shell, you can use the
   1103 <a href="http://www.sqlite.org/sqlite.html">sqlite3</a> command-line program to
   1104 manage SQLite databases created by Android applications. The
   1105 <code>sqlite3</code> tool includes many useful commands, such as
   1106 <code>.dump</code> to print out the contents of a table and
   1107 <code>.schema</code> to print the SQL CREATE statement for an existing table.
   1108 The tool also gives you the ability to execute SQLite commands on the fly.</p>
   1109 
   1110 <p>To use <code>sqlite3</code>, enter a remote shell on the emulator instance, as described above,
   1111 then invoke the tool using the <code>sqlite3</code> command. Optionally, when invoking
   1112 <code>sqlite3</code> you can specify the full path to the database you want to explore.
   1113 Emulator/device instances store SQLite3 databases in the folder
   1114 <code><span chatdir="1"><span chatindex="259474B4B070F261">/data/data/<em>&lt;package_name&gt;</em>/databases</span></span>/</code>. </p>
   1115 
   1116 <p>Here's an example: </p>
   1117 
   1118 <pre class="no-pretty-print">adb -s emulator-5554 shell
   1119 # sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db
   1120 SQLite version 3.3.12
   1121 Enter &quot;.help&quot; for instructions
   1122 <em>.... enter commands, then quit...</em>
   1123 sqlite&gt; .exit </pre>
   1124 
   1125 <p>Once you've invoked <code>sqlite3</code>, you can issue <code>sqlite3</code> commands in the
   1126 shell. To exit and return to the adb remote shell, use <code>exit</code> or <code>CTRL+D</code>.
   1127 
   1128 
   1129 
   1130 
   1131 <h3 id="screenrecord">Recording a device screen</h3>
   1132 
   1133 <p>The {@code screenrecord} command is a shell utility for recording the display of a device as you
   1134   use it. The utility records screen activity to an MPEG-4 file, which you can then download and use
   1135   as part of a video presentation. This utility is useful for developers who want to create
   1136   promotional or training videos without using a separate recording device.</p>
   1137 
   1138 <p>To use the {@code screenrecord} from the command line, type the following:
   1139 
   1140 <pre>
   1141 $ adb shell screenrecord /sdcard/demo.mp4
   1142 </pre>
   1143 
   1144 <p>Stop the screen recording by pressing Ctrl-C, otherwise the recording stops automatically
   1145 at three minutes or the time limit set by {@code --time-limit}.</p>
   1146 
   1147 <p>Here's an example recording session, using the adb shell to record the video and the
   1148 {@code pull} command to download the file from the device:<p>
   1149 
   1150 <pre>
   1151 $ adb shell
   1152 shell@ $ screenrecord --verbose /sdcard/demo.mp4
   1153 (press Ctrl-C to stop)
   1154 shell@ $ exit
   1155 $ adb pull /sdcard/demo.mp4
   1156 </pre>
   1157 
   1158 <p>The {@code screenrecord} utility can record at any supported resolution and bit rate you
   1159   request, while retaining the aspect ratio of the device display. The utility records at the native
   1160   display resolution and orientation by default, with a maximum length of three minutes.</p>
   1161 
   1162 <p>There are some known limitations of the {@code screenrecord} utility that you should be aware
   1163   of when using it:</p>
   1164 
   1165 <ul>
   1166   <li>Some devices may not be able to record at their native display resolution.
   1167     If you encounter problems with screen recording, try using a lower screen resolution.</li>
   1168   <li>Rotation of the screen during recording is not supported. If the screen does rotate during
   1169     recording, some of the screen is cut off in the recording.</li>
   1170   <li>Audio is not recorded with the video file.</li>
   1171 </ul>
   1172 
   1173 
   1174 <p class="table-caption"><strong>Table 4.</strong> {@code screenrecord} options</p>
   1175 
   1176 <table>
   1177   <tr>
   1178     <th>Options</th>
   1179     <th>Description</th>
   1180   </tr>
   1181 
   1182   <tr>
   1183     <td><code>--help</code>
   1184     </td>
   1185     <td>Displays a usage summary.</td>
   1186   </tr>
   1187 
   1188   <tr>
   1189     <td style="white-space:nowrap">
   1190       <code>--size &lt;WIDTHxHEIGHT&gt;</code>
   1191     </td>
   1192     <td>Sets the video size, for example: {@code 1280x720}. The default value is the device's main
   1193       display resolution (if supported), 1280x720 if not. For best results, use a size supported
   1194       by your device's Advanced Video Coding (AVC) encoder.</td>
   1195   </tr>
   1196 
   1197   <tr>
   1198     <td><code>--bit-rate &lt;RATE&gt;</code></td>
   1199     <td>Sets the video bit rate for the video, in megabits per second. The default value is 4Mbps.
   1200       You can increase the bit rate to improve video quality or lower it for smaller movie
   1201       files. The following example sets the recording bit rate to 6Mbps:
   1202       <pre>screenrecord --bit-rate 6000000 &#47;sdcard&#47;demo.mp4</pre>
   1203       </td>
   1204   </tr>
   1205 
   1206   <tr>
   1207     <td><code>--time-limit &lt;TIME&gt;</code></td>
   1208     <td>Sets the maximum recording time, in seconds. The default and maximum value is 180
   1209       (3 minutes).</td>
   1210   </tr>
   1211 
   1212   <tr>
   1213     <td><code>--rotate</code></td>
   1214     <td>Rotates the output 90 degrees. This feature is experimental.</td>
   1215   </tr>
   1216 
   1217   <tr>
   1218     <td><code>--verbose</code></td>
   1219     <td>Displays log information on command line screen. If you do not set this option,
   1220       the utility does not display any information while running.</td>
   1221   </tr>
   1222 
   1223 </table>
   1224 
   1225 
   1226 
   1227 
   1228 <h3 id="monkey">UI/Application Exerciser Monkey</h3>
   1229 
   1230 <p>The Monkey is a program that runs on your emulator or device and generates pseudo-random
   1231 streams of user events such as clicks, touches, or gestures, as well as a number of system-level
   1232 events.  You can use the Monkey to stress-test applications that you are developing,
   1233 in a random yet repeatable manner.</p>
   1234 
   1235 <p>The simplest way to use the monkey is with the following command, which launches your
   1236 application and sends 500 pseudo-random events to it.</p>
   1237 
   1238 <pre class="no-pretty-print">adb shell monkey -v -p your.package.name 500</pre>
   1239 
   1240 <p>For more information about command options for Monkey, see the complete
   1241 <a href="{@docRoot}tools/help/monkey.html" title="monkey">UI/Application Exerciser Monkey</a> documentation page.</p>
   1242 
   1243 
   1244 
   1245 
   1246 
   1247 <h3 id="othershellcommands">Other shell commands</h3>
   1248 
   1249 <p>For a list of all the available shell programs, use the following command:</p>
   1250 
   1251 <pre class="no-pretty-print">adb shell ls /system/bin</pre>
   1252 
   1253 <p>Help is available for most of the commands. </p>
   1254 
   1255 <p>Table 5 lists some of the more common adb shell commands.</p>
   1256 
   1257 <p class="table-caption"><strong>Table 5.</strong> Some other adb shell commands</p>
   1258 <table>
   1259 <tr>
   1260   <th>Shell Command</th>
   1261   <th>Description</th>
   1262   <th>Comments</th>
   1263 </tr>
   1264 
   1265 <tr>
   1266 <td><code>dumpsys</code></td>
   1267 <td>Dumps system data to the screen.</td>
   1268 <td rowspan=4">The <a href="{@docRoot}tools/debugging/ddms.html">Dalvik Debug Monitor Server</a>
   1269 (DDMS) tool offers integrated debug environment that you may find easier to use.</td>
   1270 </tr>
   1271 
   1272 <tr>
   1273 <td><code>dumpstate</code></td>
   1274 <td>Dumps state to a file.</td>
   1275 </tr>
   1276 
   1277 <tr>
   1278 <td><code>logcat&nbsp;[option]...&nbsp;[filter-spec]...</code></td>
   1279 <td>Enables system and app logging and prints output to the screen. </td>
   1280 </tr>
   1281 
   1282 <tr>
   1283 <td><code>dmesg</code></td>
   1284 <td>Prints kernel debugging messages to the screen. </td>
   1285 </tr>
   1286 
   1287 <tr>
   1288 <td><code>start</code></td>
   1289 <td>Starts (restarts) an emulator/device instance.</td>
   1290 <td>&nbsp;</td>
   1291 </tr>
   1292 
   1293 <tr>
   1294 <td><code>stop</code></td>
   1295 <td>Stops execution of an emulator/device instance.</td>
   1296 <td>&nbsp;</td>
   1297 </tr>
   1298 
   1299 </table>
   1300 
   1301 
   1302 
   1303 
   1304 
   1305 
   1306 
   1307 <a name="stdout"></a>
   1308 <a name="usinglogcat"></a>
   1309 <a name="outputformat"></a>
   1310 <a name="filteringoutput"></a>
   1311 <a name="stdout"></a>
   1312 <a name="logcatoptions"></a>
   1313 
   1314 <h2 id="logcat">Enabling logcat logging</h2>
   1315 
   1316 <p>The Android logging system provides a mechanism for collecting and viewing system debug output. Logs from various applications and portions of the system are collected in a series of circular buffers, which then can be viewed and filtered by the <code>logcat</code> command.</p>
   1317 
   1318 <p>You can use the <code>logcat</code> command to view and follow the contents of the system's log buffers. The general usage is:</p>
   1319 
   1320 <pre class="no-pretty-print">[adb] logcat [option] ... [filter-spec] ...</pre>
   1321 
   1322 <p>You can use the <code>logcat</code> command from your development computer  or from a remote adb shell in an emulator/device instance. To view log output in your development computer, you use</p>
   1323 
   1324 <pre class="no-pretty-print">adb logcat</pre>
   1325 
   1326 <p>and from a remote adb shell you use</p>
   1327 
   1328 <pre class="no-pretty-print">logcat</pre>
   1329 
   1330 <p>See <a href="{@docRoot}tools/debugging/debugging-log.html">Reading and Writing Logs</a> for complete information about logcat commend options and filter specifications.</p>
   1331 
   1332 
   1333 
   1334 
   1335 
   1336 <h2 id="stopping">Stopping the adb server</h2>
   1337 
   1338 <p>In some cases, you might need to terminate the adb server process and then restart it. For example, if adb does not respond to a command, you can terminate the server and restart it and that may resolve the problem. </p>
   1339 
   1340 <p>To stop the adb server, use the <code>kill-server</code> command.
   1341 You can then restart the server by issuing any other adb command. </p>
   1342 
   1343 
   1344