1page.title=Developing on a Device 2@jd:body 3 4<div id="qv-wrapper"> 5<div id="qv"> 6 <h2>In this document</h2> 7 <ol> 8 <li><a href="#setting-up">Setting up a Device for Development</a> 9 <ol> 10 <li><a href="#VendorIds">USB Vendor IDs</a></li> 11 </ol> 12 </li> 13 </ol> 14 <h2>See also</h2> 15 <ol> 16 <li><a href="{@docRoot}sdk/win-usb.html">Google USB Driver</a></li> 17 <li><a href="{@docRoot}sdk/oem-usb.html">OEM USB Drivers</a></li> 18 <li><a 19href="{@docRoot}guide/developing/eclipse-adt.html">Developing in Eclipse, with ADT</a></li> 20 <li><a 21href="{@docRoot}guide/developing/other-ide.html">Developing in other IDEs</a></li> 22 </ol> 23</div> 24</div> 25 26<p>When building a mobile application, it's important that you always test your application on a 27real device before releasing it to users. This page describes how to set up your development 28environment and Android-powered device for testing and debugging on the device.</p> 29 30<p>You can use any Android-powered device as an environment for running, 31debugging, and testing your applications. The tools included in the SDK make it easy to install and 32run your application on the device each time you compile. You can install your application on the 33device <a 34href="{@docRoot}guide/developing/eclipse-adt.html#RunningOnDevice">directly from 35Eclipse</a> or <a href="{@docRoot}guide/developing/other-ide.html#RunningOnDevice">from the 36command line</a>. If 37you don't yet have a device, check with the service providers in your area to determine which 38Android-powered devices are available.</p> 39 40<p>If you want a SIM-unlocked phone, then you might consider either an Android Dev Phone or the 41Google Nexus S. These are SIM-unlocked so that you can use them on any GSM network using a SIM 42card. The Android Dev Phones also feature an unlocked bootloader so you can install custom system 43images (great for developing and installing custom versions of the Android platform). To find a 44a place you can purchase the Nexus S, visit <a 45href="http://www.google.com/phone/detail/nexus-s">google.com/phone</a>. To purchase an Android 46Dev Phone, see the <a href="http://market.android.com/publish">Android Market</a> site 47(requires a developer account).</p> 48 49<p class="note"><strong>Note:</strong> When developing on a device, keep in mind that you should 50still use the <a 51href="{@docRoot}guide/developing/tools/emulator.html">Android emulator</a> to test your application 52on configurations that are not equivalent to those of your real device. Although the emulator 53does not allow you to test every device feature (such as the accelerometer), it does 54allow you to verify that your application functions properly on different versions of the Android 55platform, in different screen sizes and orientations, and more.</p> 56 57 58<h2 id="setting-up">Setting up a Device for Development</h2> 59 60<p>With an Android-powered device, you can develop and debug your Android applications just as you 61would on the emulator. Before you can start, there are just a few things to do:</p> 62 63<ol> 64 <li>Declare your application as "debuggable" in your Android Manifest. 65 <p>In Eclipse, you can do this from the <b>Application</b> tab when viewing the Manifest 66 (on the right side, set <b>Debuggable</b> to <em>true</em>). Otherwise, in the <code>AndroidManifest.xml</code> 67 file, add <code>android:debuggable="true"</code> to the <code><application></code> element.</p> 68 </li> 69 <li>Turn on "USB Debugging" on your device. 70 <p>On the device, go to the home screen, press <b>MENU</b>, select <b>Applications</b> > <b>Development</b>, 71 then enable <b>USB debugging</b>.</p> 72 </li> 73 <li>Setup your system to detect your device. 74 <ul> 75 <li>If you're developing on Windows, you need to install a USB driver 76 for adb. If you're using an Android Developer Phone (ADP), Nexus One, or Nexus S, 77 see the <a href="{@docRoot}sdk/win-usb.html">Google Windows USB 78 Driver</a>. Otherwise, you can find a link to the appropriate OEM driver in the 79 <a href="{@docRoot}sdk/oem-usb.html">OEM USB Drivers</a> document.</li> 80 <li>If you're developing on Mac OS X, it just works. Skip this step.</li> 81 <li>If you're developing on Ubuntu Linux, you need to add a rules file 82that contains a USB configuration for each type of device you want to use for 83development. Each device manufacturer uses a different vendor ID. The 84example rules files below show how to add an entry for a single vendor ID 85(the HTC vendor ID). In order to support more devices, you will need additional 86lines of the same format that provide a different value for the 87<code>SYSFS{idVendor}</code> property. For other IDs, see the table of <a 88href="#VendorIds">USB Vendor IDs</a>, below. 89 <ol> 90 <li>Log in as root and create this file: 91 <code>/etc/udev/rules.d/51-android.rules</code>. 92 <p>For Gusty/Hardy, edit the file to read:<br/> 93 <code>SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", 94 MODE="0666"</code></p> 95 96 <p>For Dapper, edit the file to read:<br/> 97 <code>SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", 98 MODE="0666"</code></p> 99 </li> 100 <li>Now execute:<br/> 101 <code>chmod a+r /etc/udev/rules.d/51-android.rules</code> 102 </li> 103 </ol> 104 </li> 105 </ul> 106 </li> 107</ol> 108 109<p>You can verify that your device is connected by executing <code>adb devices</code> from your 110SDK {@code platform-tools/} directory. If connected, you'll see the device name listed as a 111"device."</p> 112 113<p>If using Eclipse, run or debug as usual. You will be presented 114with a <b>Device Chooser</b> dialog that lists the available emulator(s) and connected device(s). 115Select the device upon which you want to install and run the application.</p> 116 117<p>If using the <a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a> (adb), 118you can issue commands with the <code>-d</code> flag to target your 119connected device.</p> 120 121 122<h3 id="VendorIds">USB Vendor IDs</h3> 123<p>This table provides a reference to the vendor IDs needed in order to add 124USB device support on Linux. The USB Vendor ID is the value given to the 125<code>SYSFS{idVendor}</code> property in the rules file, as described in step 3, above.</p> 126 127<table> 128 <tr> 129 <th>Manufacturer</th><th>USB Vendor ID</th></tr> 130 <tr> 131 <td>Acer</td> 132 <td><code>0502</code></td></tr> 133 <tr> 134 <td>Dell</td> 135 <td><code>413c</code></td></tr> 136 <tr> 137 <td>Foxconn</td> 138 <td><code>0489</code></td></tr> 139 <tr> 140 <td>Garmin-Asus</td> 141 <td><code>091E</code></td></tr> 142 <tr> 143 <td>HTC</td> 144 <td><code>0bb4</code></td></tr> 145 <tr> 146 <td>Huawei</td> 147 <td><code>12d1</code></td></tr> 148 <tr> 149 <td>Kyocera</td> 150 <td><code>0482</code></td></tr> 151 <tr> 152 <td>LG</td> 153 <td><code>1004</code></td></tr> 154 <tr> 155 <td>Motorola</td> 156 <td><code>22b8</code></td></tr> 157 <tr> 158 <td>Nvidia</td> 159 <td><code>0955</code></td></tr> 160 <tr> 161 <td>Pantech</td> 162 <td><code>10A9</code></td></tr> 163 <tr> 164 <td>Samsung</td> 165 <td><code>04e8</code></td></tr> 166 <tr> 167 <td>Sharp</td> 168 <td><code>04dd</code></td></tr> 169 <tr> 170 <td>Sony Ericsson</td> 171 <td><code>0fce</code></td></tr> 172 <tr> 173 <td>ZTE</td> 174 <td><code>19D2</code></td></tr> 175</table> 176