| 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/> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 98 | <code>SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"</code> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 99 | <br /><br /> |
| 100 | |
| 101 | In this example, the vendor ID is for HTC. The <code>MODE</code> |
| 102 | assignment specifies read/write permissions, and <code>GROUP</code> defines |
| 103 | which Unix group owns the device node. </p> |
| 104 | |
| 105 | <p class="note"><strong>Note:</strong> The rule syntax |
| 106 | may vary slightly depending on your environment. Consult the <code>udev</code> |
| 107 | documentation for your system as needed. For an overview of rule syntax, see |
| 108 | this guide to <a |
| 109 | href="http://www.reactivated.net/writing_udev_rules.html">writing udev |
| 110 | rules</a>.</p> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | </li> |
| 112 | <li>Now execute:<br/> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 113 | <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] | 114 | </li> |
| 115 | </ol> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | </li> |
| 117 | </ul> |
| 118 | </li> |
| 119 | </ol> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 120 | |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 121 | <p>You can verify that your device is connected by executing <code>adb |
| 122 | devices</code> from your SDK {@code platform-tools/} directory. If connected, |
| 123 | you'll see the device name listed as a "device."</p> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 124 | |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 125 | <p>If using Eclipse, run or debug your application as usual. You will be |
| 126 | presented with a <b>Device Chooser</b> dialog that lists the available |
| 127 | emulator(s) and connected device(s). Select the device upon which you want to |
| 128 | install and run the application.</p> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 129 | |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 130 | <p>If using the <a href="{@docRoot}guide/developing/tools/adb.html">Android |
| 131 | Debug Bridge</a> (adb), you can issue commands with the <code>-d</code> flag to |
| 132 | target your connected device.</p> |
| Scott Main | 7991745 | 2009-08-26 11:56:57 -0700 | [diff] [blame] | 133 | |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 134 | <h3 id="VendorIds">USB Vendor IDs</h3> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 135 | |
| 136 | <p>This table provides a reference to the vendor IDs needed in order to add USB |
| 137 | device support on Linux. The USB Vendor ID is the value given to the |
| 138 | <code>ATTR{idVendor}</code> property in the rules file, as described |
| 139 | above.</p> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 140 | |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 141 | <table> |
| 142 | <tr> |
| Scott Main | 2785443 | 2011-03-08 16:32:09 -0800 | [diff] [blame] | 143 | <th>Company</th><th>USB Vendor ID</th></tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 144 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 145 | <td>Acer</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 146 | <td><code>0502</code></td> |
| 147 | </tr> |
| 148 | <tr> |
| 149 | <td>ASUS</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 150 | <td><code>0B05</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 151 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 152 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 153 | <td>Dell</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 154 | <td><code>413C</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 155 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 156 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 157 | <td>Foxconn</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 158 | <td><code>0489</code></td> |
| 159 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 160 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 161 | <td>Garmin-Asus</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 162 | <td><code>091E</code></td> |
| 163 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 164 | <tr> |
| Scott Main | 2785443 | 2011-03-08 16:32:09 -0800 | [diff] [blame] | 165 | <td>Google</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 166 | <td><code>18D1</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 167 | </tr> |
| Scott Main | 2785443 | 2011-03-08 16:32:09 -0800 | [diff] [blame] | 168 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 169 | <td>HTC</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 170 | <td><code>0BB4</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 171 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 172 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 173 | <td>Huawei</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 174 | <td><code>12D1</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 175 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 176 | <tr> |
| Scott Main | 3e485d0 | 2011-07-13 09:36:56 -0700 | [diff] [blame] | 177 | <td>K-Touch</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 178 | <td><code>24E3</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 179 | </tr> |
| 180 | <tr> |
| 181 | <td>KT Tech</td> |
| 182 | <td><code>2116</code></td> |
| 183 | </tr> |
| Scott Main | 3e485d0 | 2011-07-13 09:36:56 -0700 | [diff] [blame] | 184 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 185 | <td>Kyocera</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 186 | <td><code>0482</code></td> |
| 187 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 188 | <tr> |
| Scott Main | ea41e8d | 2011-06-20 15:50:12 -0700 | [diff] [blame] | 189 | <td>Lenevo</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 190 | <td><code>17EF</code></td> |
| 191 | </tr> |
| Scott Main | ea41e8d | 2011-06-20 15:50:12 -0700 | [diff] [blame] | 192 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 193 | <td>LG</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 194 | <td><code>1004</code></td> |
| 195 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 196 | <tr> |
| 197 | <td>Motorola</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 198 | <td><code>22B8</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 199 | </tr> |
| 200 | <tr> |
| 201 | <td>NEC</td> |
| 202 | <td><code>0409</code></td> |
| 203 | </tr> |
| 204 | <tr> |
| 205 | <td>Nook</td> |
| 206 | <td><code>2080</code></td> |
| 207 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 208 | <tr> |
| 209 | <td>Nvidia</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 210 | <td><code>0955</code></td> |
| 211 | </tr> |
| 212 | <tr> |
| 213 | <td>OTGV</td> |
| 214 | <td><code>2257</code></td> |
| 215 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 216 | <tr> |
| 217 | <td>Pantech</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 218 | <td><code>10A9</code></td> |
| 219 | </tr> |
| 220 | <tr> |
| 221 | <td>Pegatron</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 222 | <td><code>1D4D</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 223 | </tr> |
| 224 | <tr> |
| 225 | <td>Philips</td> |
| 226 | <td><code>0471</code></td> |
| 227 | </tr> |
| 228 | <tr> |
| 229 | <td>PMC-Sierra</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 230 | <td><code>04DA</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 231 | </tr> |
| 232 | <tr> |
| 233 | <td>Qualcomm</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 234 | <td><code>05C6</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 235 | </tr> |
| 236 | <tr> |
| 237 | <td>SK Telesys</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 238 | <td><code>1F53</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 239 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 240 | <tr> |
| 241 | <td>Samsung</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 242 | <td><code>04E8</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 243 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 244 | <tr> |
| 245 | <td>Sharp</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 246 | <td><code>04DD</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 247 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 248 | <tr> |
| 249 | <td>Sony Ericsson</td> |
| Scott Main | 9fe4459 | 2011-08-26 12:42:49 -0700 | [diff] [blame^] | 250 | <td><code>0FCE</code></td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 251 | </tr> |
| 252 | <tr> |
| 253 | <td>Toshiba</td> |
| 254 | <td><code>0930</code></td> |
| 255 | </tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 256 | <tr> |
| 257 | <td>ZTE</td> |
| Scott Main | 6922492 | 2011-08-26 11:50:36 -0700 | [diff] [blame] | 258 | <td><code>19D2</code></td> |
| 259 | </tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 260 | </table> |