| Scott Main | 300cd26 | 2011-02-08 15:04:42 -0800 | [diff] [blame] | 1 | page.title=Using Hardware Devices |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2 | @jd:body |
| 3 | |
| 4 | <div id="qv-wrapper"> |
| 5 | <div id="qv"> |
| 6 | <h2>In this document</h2> |
| 7 | <ol> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 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> |
| Scott Main | 0f80563 | 2011-01-07 10:45:03 -0800 | [diff] [blame] | 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> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | </ol> |
| 19 | </div> |
| 20 | </div> |
| 21 | |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 22 | <p>When building a mobile application, it's important that you always test your application on a |
| 23 | real device before releasing it to users. This page describes how to set up your development |
| 24 | environment and Android-powered device for testing and debugging on the device.</p> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 26 | <p>You can use any Android-powered device as an environment for running, |
| 27 | debugging, and testing your applications. The tools included in the SDK make it easy to install and |
| 28 | run your application on the device each time you compile. You can install your application on the |
| Robert Ly | ee2dacd1 | 2010-12-22 09:46:12 -0800 | [diff] [blame] | 29 | device directly from Eclipse or from the command line with ADB. If |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 30 | you don't yet have a device, check with the service providers in your area to determine which |
| 31 | Android-powered devices are available.</p> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 33 | <p>If you want a SIM-unlocked phone, then you might consider either an Android Dev Phone or the |
| Scott Main | 955c63f | 2011-01-07 13:46:42 -0800 | [diff] [blame] | 34 | Google Nexus S. These are SIM-unlocked so that you can use them on any GSM network using a SIM |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 35 | card. The Android Dev Phones also feature an unlocked bootloader so you can install custom system |
| Scott Main | 955c63f | 2011-01-07 13:46:42 -0800 | [diff] [blame] | 36 | images (great for developing and installing custom versions of the Android platform). To find a |
| 37 | a place you can purchase the Nexus S, visit <a |
| 38 | href="http://www.google.com/phone/detail/nexus-s">google.com/phone</a>. To purchase an Android |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 39 | Dev Phone, see the <a href="http://market.android.com/publish">Android Market</a> site |
| 40 | (requires a developer account).</p> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 42 | <p class="note"><strong>Note:</strong> When developing on a device, keep in mind that you should |
| 43 | still use the <a |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 44 | href="{@docRoot}guide/developing/devices/emulator.html">Android emulator</a> to test your |
| 45 | application |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 46 | on configurations that are not equivalent to those of your real device. Although the emulator |
| 47 | does not allow you to test every device feature (such as the accelerometer), it does |
| 48 | allow you to verify that your application functions properly on different versions of the Android |
| 49 | platform, in different screen sizes and orientations, and more.</p> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | |
| Scott Main | 7991745 | 2009-08-26 11:56:57 -0700 | [diff] [blame] | 51 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | <h2 id="setting-up">Setting up a Device for Development</h2> |
| 53 | |
| Scott Main | 7991745 | 2009-08-26 11:56:57 -0700 | [diff] [blame] | 54 | <p>With an Android-powered device, you can develop and debug your Android applications just as you |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 55 | would on the emulator. Before you can start, there are just a few things to do:</p> |
| 56 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | <ol> |
| 58 | <li>Declare your application as "debuggable" in your Android Manifest. |
| 59 | <p>In Eclipse, you can do this from the <b>Application</b> tab when viewing the Manifest |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 60 | (on the right side, set <b>Debuggable</b> to <em>true</em>). Otherwise, in the |
| 61 | <code>AndroidManifest.xml</code> |
| 62 | file, add <code>android:debuggable="true"</code> to the <code><application></code> |
| 63 | element.</p> |
| 64 | </li> |
| 65 | <li>Set up your device to allow installation of non-Market applications. <p>On |
| 66 | the device, go to <strong>Settings > Applications</strong> and enable |
| 67 | |
| 68 | <strong>Unknown sources</strong>.</p> |
| 69 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | </li> |
| 71 | <li>Turn on "USB Debugging" on your device. |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 72 | <p>On the device, go to <strong>Settings > Applications > Development</strong> |
| 73 | and enable <strong>USB debugging</strong>.</p> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | </li> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 75 | <li>Set up your system to detect your device. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | <ul> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 77 | <li>If you're developing on Windows, you need to install a USB driver |
| Scott Main | 0f80563 | 2011-01-07 10:45:03 -0800 | [diff] [blame] | 78 | for adb. If you're using an Android Developer Phone (ADP), Nexus One, or Nexus S, |
| 79 | see the <a href="{@docRoot}sdk/win-usb.html">Google Windows USB |
| 80 | Driver</a>. Otherwise, you can find a link to the appropriate OEM driver in the |
| 81 | <a href="{@docRoot}sdk/oem-usb.html">OEM USB Drivers</a> document.</li> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | <li>If you're developing on Mac OS X, it just works. Skip this step.</li> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 83 | |
| 84 | <li>If you're developing on Ubuntu Linux, you need to add a <a |
| 85 | href="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"> |
| 86 | <code>udev</code></a> |
| 87 | rules file that contains a USB configuration for each type of device |
| 88 | you want to use for development. In the rules file, each device manufacturer |
| 89 | is identified by a unique vendor ID, as specified by the |
| 90 | <code>ATTR{idVendor}</code> property. For a list of vendor IDs, see <a |
| 91 | href="#VendorIds">USB Vendor IDs</a>, below. To set up device detection on |
| 92 | Ubuntu Linux: |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 94 | <ol type="a"> |
| 95 | <li>Log in as root and create this file: |
| 96 | <code>/etc/udev/rules.d/51-android.rules</code></span>. |
| 97 | <p>Use this format to add each vendor to the file:<br/> |
| 98 | <code>SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", |
| 99 | MODE="0666", GROUP="plugdev"</code> |
| 100 | <br /><br /> |
| 101 | |
| 102 | In this example, the vendor ID is for HTC. The <code>MODE</code> |
| 103 | assignment specifies read/write permissions, and <code>GROUP</code> defines |
| 104 | which Unix group owns the device node. </p> |
| 105 | |
| 106 | <p class="note"><strong>Note:</strong> The rule syntax |
| 107 | may vary slightly depending on your environment. Consult the <code>udev</code> |
| 108 | documentation for your system as needed. For an overview of rule syntax, see |
| 109 | this guide to <a |
| 110 | href="http://www.reactivated.net/writing_udev_rules.html">writing udev |
| 111 | rules</a>.</p> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | </li> |
| 113 | <li>Now execute:<br/> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 114 | <code>chmod a+r /etc/udev/rules.d/51-android.rules</code> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 115 | </li> |
| 116 | </ol> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | </li> |
| 118 | </ul> |
| 119 | </li> |
| 120 | </ol> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 121 | |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 122 | <p>You can verify that your device is connected by executing <code>adb |
| 123 | devices</code> from your SDK {@code platform-tools/} directory. If connected, |
| 124 | you'll see the device name listed as a "device."</p> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 125 | |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 126 | <p>If using Eclipse, run or debug your application as usual. You will be |
| 127 | presented with a <b>Device Chooser</b> dialog that lists the available |
| 128 | emulator(s) and connected device(s). Select the device upon which you want to |
| 129 | install and run the application.</p> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 130 | |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 131 | <p>If using the <a href="{@docRoot}guide/developing/tools/adb.html">Android |
| 132 | Debug Bridge</a> (adb), you can issue commands with the <code>-d</code> flag to |
| 133 | target your connected device.</p> |
| Scott Main | 7991745 | 2009-08-26 11:56:57 -0700 | [diff] [blame] | 134 | |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 135 | <h3 id="VendorIds">USB Vendor IDs</h3> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 136 | |
| 137 | <p>This table provides a reference to the vendor IDs needed in order to add USB |
| 138 | device support on Linux. The USB Vendor ID is the value given to the |
| 139 | <code>ATTR{idVendor}</code> property in the rules file, as described |
| 140 | above.</p> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 141 | |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 142 | <table> |
| 143 | <tr> |
| Scott Main | 2785443 | 2011-03-08 16:32:09 -0800 | [diff] [blame] | 144 | <th>Company</th><th>USB Vendor ID</th></tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 145 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 146 | <td>Acer</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 147 | <td><code>0502</code></td> |
| 148 | </tr> |
| 149 | <tr> |
| 150 | <td>ASUS</td> |
| 151 | <td><code>0b05</code></td> |
| 152 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 153 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 154 | <td>Dell</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 155 | <td><code>413c</code></td> |
| 156 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 157 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 158 | <td>Foxconn</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 159 | <td><code>0489</code></td> |
| 160 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 161 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 162 | <td>Garmin-Asus</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 163 | <td><code>091E</code></td> |
| 164 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 165 | <tr> |
| Scott Main | 2785443 | 2011-03-08 16:32:09 -0800 | [diff] [blame] | 166 | <td>Google</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 167 | <td><code>18d1</code></td> |
| 168 | </tr> |
| Scott Main | 2785443 | 2011-03-08 16:32:09 -0800 | [diff] [blame] | 169 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 170 | <td>HTC</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 171 | <td><code>0bb4</code></td> |
| 172 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 173 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 174 | <td>Huawei</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 175 | <td><code>12d1</code></td> |
| 176 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 177 | <tr> |
| Scott Main | 3e485d0 | 2011-07-13 09:36:56 -0700 | [diff] [blame] | 178 | <td>K-Touch</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 179 | <td><code>24e3</code></td> |
| 180 | </tr> |
| 181 | <tr> |
| 182 | <td>KT Tech</td> |
| 183 | <td><code>2116</code></td> |
| 184 | </tr> |
| Scott Main | 3e485d0 | 2011-07-13 09:36:56 -0700 | [diff] [blame] | 185 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 186 | <td>Kyocera</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 187 | <td><code>0482</code></td> |
| 188 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 189 | <tr> |
| Scott Main | ea41e8d | 2011-06-20 15:50:12 -0700 | [diff] [blame] | 190 | <td>Lenevo</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 191 | <td><code>17EF</code></td> |
| 192 | </tr> |
| Scott Main | ea41e8d | 2011-06-20 15:50:12 -0700 | [diff] [blame] | 193 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 194 | <td>LG</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 195 | <td><code>1004</code></td> |
| 196 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 197 | <tr> |
| 198 | <td>Motorola</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 199 | <td><code>22b8</code></td> |
| 200 | </tr> |
| 201 | <tr> |
| 202 | <td>NEC</td> |
| 203 | <td><code>0409</code></td> |
| 204 | </tr> |
| 205 | <tr> |
| 206 | <td>Nook</td> |
| 207 | <td><code>2080</code></td> |
| 208 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 209 | <tr> |
| 210 | <td>Nvidia</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 211 | <td><code>0955</code></td> |
| 212 | </tr> |
| 213 | <tr> |
| 214 | <td>OTGV</td> |
| 215 | <td><code>2257</code></td> |
| 216 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 217 | <tr> |
| 218 | <td>Pantech</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 219 | <td><code>10A9</code></td> |
| 220 | </tr> |
| 221 | <tr> |
| 222 | <td>Pegatron</td> |
| 223 | <td><code>0x1D4D</code></td> |
| 224 | </tr> |
| 225 | <tr> |
| 226 | <td>Philips</td> |
| 227 | <td><code>0471</code></td> |
| 228 | </tr> |
| 229 | <tr> |
| 230 | <td>PMC-Sierra</td> |
| 231 | <td><code>04da</code></td> |
| 232 | </tr> |
| 233 | <tr> |
| 234 | <td>Qualcomm</td> |
| 235 | <td><code>05c6</code></td> |
| 236 | </tr> |
| 237 | <tr> |
| 238 | <td>SK Telesys</td> |
| 239 | <td><code>1f53</code></td> |
| 240 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 241 | <tr> |
| Scott Main | a04f132 | 2011-08-24 19:27:25 -0700 | [diff] [blame] | 242 | <td>Pegatron</td> |
| 243 | <td><code>0x1D4D</code></td></tr> |
| 244 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 245 | <td>Samsung</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 246 | <td><code>04e8</code></td> |
| 247 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 248 | <tr> |
| 249 | <td>Sharp</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 250 | <td><code>04dd</code></td> |
| 251 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 252 | <tr> |
| 253 | <td>Sony Ericsson</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 254 | <td><code>0fce</code></td> |
| 255 | </tr> |
| 256 | <tr> |
| 257 | <td>Toshiba</td> |
| 258 | <td><code>0930</code></td> |
| 259 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 260 | <tr> |
| 261 | <td>ZTE</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 262 | <td><code>19D2</code></td> |
| 263 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 264 | </table> |