blob: e08119fa61094928a699841ef69c198c8e09cb25 [file] [log] [blame]
Scott Main300cd262011-02-08 15:04:42 -08001page.title=Using Hardware Devices
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002@jd:body
3
4<div id="qv-wrapper">
5<div id="qv">
6 <h2>In this document</h2>
7 <ol>
Scott Mainad68fdd2009-11-05 18:53:59 -08008 <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 Main0f805632011-01-07 10:45:03 -080016 <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 Project9066cfe2009-03-03 19:31:44 -080018 </ol>
19</div>
20</div>
21
Scott Main01979992010-04-05 17:42:17 -070022<p>When building a mobile application, it's important that you always test your application on a
23real device before releasing it to users. This page describes how to set up your development
24environment and Android-powered device for testing and debugging on the device.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025
Scott Main01979992010-04-05 17:42:17 -070026<p>You can use any Android-powered device as an environment for running,
27debugging, and testing your applications. The tools included in the SDK make it easy to install and
28run your application on the device each time you compile. You can install your application on the
Robert Lyee2dacd12010-12-22 09:46:12 -080029device directly from Eclipse or from the command line with ADB. If
Scott Main01979992010-04-05 17:42:17 -070030you don't yet have a device, check with the service providers in your area to determine which
31Android-powered devices are available.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032
Scott Main01979992010-04-05 17:42:17 -070033<p>If you want a SIM-unlocked phone, then you might consider either an Android Dev Phone or the
Scott Main955c63f2011-01-07 13:46:42 -080034Google Nexus S. These are SIM-unlocked so that you can use them on any GSM network using a SIM
Scott Main01979992010-04-05 17:42:17 -070035card. The Android Dev Phones also feature an unlocked bootloader so you can install custom system
Scott Main955c63f2011-01-07 13:46:42 -080036images (great for developing and installing custom versions of the Android platform). To find a
37a place you can purchase the Nexus S, visit <a
38href="http://www.google.com/phone/detail/nexus-s">google.com/phone</a>. To purchase an Android
Scott Main01979992010-04-05 17:42:17 -070039Dev Phone, see the <a href="http://market.android.com/publish">Android Market</a> site
40(requires a developer account).</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041
Scott Main01979992010-04-05 17:42:17 -070042<p class="note"><strong>Note:</strong> When developing on a device, keep in mind that you should
43still use the <a
Scott Main69224922011-08-26 11:50:36 -070044href="{@docRoot}guide/developing/devices/emulator.html">Android emulator</a> to test your
45application
Scott Main01979992010-04-05 17:42:17 -070046on configurations that are not equivalent to those of your real device. Although the emulator
47does not allow you to test every device feature (such as the accelerometer), it does
48allow you to verify that your application functions properly on different versions of the Android
49platform, in different screen sizes and orientations, and more.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050
Scott Main79917452009-08-26 11:56:57 -070051
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052<h2 id="setting-up">Setting up a Device for Development</h2>
53
Scott Main79917452009-08-26 11:56:57 -070054<p>With an Android-powered device, you can develop and debug your Android applications just as you
Scott Main01979992010-04-05 17:42:17 -070055would on the emulator. Before you can start, there are just a few things to do:</p>
56
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057<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 Main69224922011-08-26 11:50:36 -070060 (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>&lt;application></code>
63element.</p>
64 </li>
65 <li>Set up your device to allow installation of non-Market applications. <p>On
66the device, go to <strong>Settings > Applications</strong> and enable
67
68<strong>Unknown sources</strong>.</p>
69
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070 </li>
71 <li>Turn on "USB Debugging" on your device.
Scott Main69224922011-08-26 11:50:36 -070072 <p>On the device, go to <strong>Settings > Applications > Development</strong>
73 and enable <strong>USB debugging</strong>.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074 </li>
Scott Main69224922011-08-26 11:50:36 -070075 <li>Set up your system to detect your device.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076 <ul>
Scott Mainad68fdd2009-11-05 18:53:59 -080077 <li>If you're developing on Windows, you need to install a USB driver
Scott Main0f805632011-01-07 10:45:03 -080078 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 Project9066cfe2009-03-03 19:31:44 -080082 <li>If you're developing on Mac OS X, it just works. Skip this step.</li>
Scott Main69224922011-08-26 11:50:36 -070083
84 <li>If you're developing on Ubuntu Linux, you need to add a <a
85href="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html">
86<code>udev</code></a>
87rules file that contains a USB configuration for each type of device
88you want to use for development. In the rules file, each device manufacturer
89is identified by a unique vendor ID, as specified by the
90<code>ATTR{idVendor}</code> property. For a list of vendor IDs, see <a
91href="#VendorIds">USB Vendor IDs</a>, below. To set up device detection on
92Ubuntu Linux:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093
Scott Main69224922011-08-26 11:50:36 -070094 <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 Main9fe44592011-08-26 12:42:49 -070098 <code>SUBSYSTEM==&quot;usb&quot;, ATTR{idVendor}==&quot;0bb4&quot;, MODE=&quot;0666&quot;, GROUP=&quot;plugdev&quot;</code>
Scott Main69224922011-08-26 11:50:36 -070099 <br /><br />
100
101 In this example, the vendor ID is for HTC. The <code>MODE</code>
102assignment specifies read/write permissions, and <code>GROUP</code> defines
103which Unix group owns the device node. </p>
104
105 <p class="note"><strong>Note:</strong> The rule syntax
106may vary slightly depending on your environment. Consult the <code>udev</code>
107documentation for your system as needed. For an overview of rule syntax, see
108this guide to <a
109href="http://www.reactivated.net/writing_udev_rules.html">writing udev
110rules</a>.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800111 </li>
112 <li>Now execute:<br/>
Scott Main69224922011-08-26 11:50:36 -0700113 <code>chmod a+r /etc/udev/rules.d/51-android.rules</code>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800114 </li>
115 </ol>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800116 </li>
117 </ul>
118 </li>
119</ol>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800120
Scott Main69224922011-08-26 11:50:36 -0700121<p>You can verify that your device is connected by executing <code>adb
122devices</code> from your SDK {@code platform-tools/} directory. If connected,
123you'll see the device name listed as a "device."</p>
Scott Main01979992010-04-05 17:42:17 -0700124
Scott Main69224922011-08-26 11:50:36 -0700125<p>If using Eclipse, run or debug your application as usual. You will be
126presented with a <b>Device Chooser</b> dialog that lists the available
127emulator(s) and connected device(s). Select the device upon which you want to
128install and run the application.</p>
Scott Main01979992010-04-05 17:42:17 -0700129
Scott Main69224922011-08-26 11:50:36 -0700130<p>If using the <a href="{@docRoot}guide/developing/tools/adb.html">Android
131Debug Bridge</a> (adb), you can issue commands with the <code>-d</code> flag to
132target your connected device.</p>
Scott Main79917452009-08-26 11:56:57 -0700133
Scott Mainad68fdd2009-11-05 18:53:59 -0800134<h3 id="VendorIds">USB Vendor IDs</h3>
Scott Main69224922011-08-26 11:50:36 -0700135
136<p>This table provides a reference to the vendor IDs needed in order to add USB
137device 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
139above.</p>
Scott Main01979992010-04-05 17:42:17 -0700140
Scott Mainad68fdd2009-11-05 18:53:59 -0800141<table>
142 <tr>
Scott Main27854432011-03-08 16:32:09 -0800143 <th>Company</th><th>USB Vendor ID</th></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800144 <tr>
Scott Main01979992010-04-05 17:42:17 -0700145 <td>Acer</td>
Scott Main69224922011-08-26 11:50:36 -0700146 <td><code>0502</code></td>
147 </tr>
148 <tr>
149 <td>ASUS</td>
Scott Main9fe44592011-08-26 12:42:49 -0700150 <td><code>0B05</code></td>
Scott Main69224922011-08-26 11:50:36 -0700151 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800152 <tr>
Scott Main01979992010-04-05 17:42:17 -0700153 <td>Dell</td>
Scott Main9fe44592011-08-26 12:42:49 -0700154 <td><code>413C</code></td>
Scott Main69224922011-08-26 11:50:36 -0700155 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800156 <tr>
Scott Main01979992010-04-05 17:42:17 -0700157 <td>Foxconn</td>
Scott Main69224922011-08-26 11:50:36 -0700158 <td><code>0489</code></td>
159 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800160 <tr>
Scott Main01979992010-04-05 17:42:17 -0700161 <td>Garmin-Asus</td>
Scott Main69224922011-08-26 11:50:36 -0700162 <td><code>091E</code></td>
163 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800164 <tr>
Scott Main27854432011-03-08 16:32:09 -0800165 <td>Google</td>
Scott Main9fe44592011-08-26 12:42:49 -0700166 <td><code>18D1</code></td>
Scott Main69224922011-08-26 11:50:36 -0700167 </tr>
Scott Main27854432011-03-08 16:32:09 -0800168 <tr>
Scott Main01979992010-04-05 17:42:17 -0700169 <td>HTC</td>
Scott Main9fe44592011-08-26 12:42:49 -0700170 <td><code>0BB4</code></td>
Scott Main69224922011-08-26 11:50:36 -0700171 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800172 <tr>
Scott Main01979992010-04-05 17:42:17 -0700173 <td>Huawei</td>
Scott Main9fe44592011-08-26 12:42:49 -0700174 <td><code>12D1</code></td>
Scott Main69224922011-08-26 11:50:36 -0700175 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800176 <tr>
Scott Main3e485d02011-07-13 09:36:56 -0700177 <td>K-Touch</td>
Scott Main9fe44592011-08-26 12:42:49 -0700178 <td><code>24E3</code></td>
Scott Main69224922011-08-26 11:50:36 -0700179 </tr>
180 <tr>
181 <td>KT Tech</td>
182 <td><code>2116</code></td>
183 </tr>
Scott Main3e485d02011-07-13 09:36:56 -0700184 <tr>
Scott Main01979992010-04-05 17:42:17 -0700185 <td>Kyocera</td>
Scott Main69224922011-08-26 11:50:36 -0700186 <td><code>0482</code></td>
187 </tr>
Scott Main01979992010-04-05 17:42:17 -0700188 <tr>
Scott Mainea41e8d2011-06-20 15:50:12 -0700189 <td>Lenevo</td>
Scott Main69224922011-08-26 11:50:36 -0700190 <td><code>17EF</code></td>
191 </tr>
Scott Mainea41e8d2011-06-20 15:50:12 -0700192 <tr>
Scott Main01979992010-04-05 17:42:17 -0700193 <td>LG</td>
Scott Main69224922011-08-26 11:50:36 -0700194 <td><code>1004</code></td>
195 </tr>
Scott Main01979992010-04-05 17:42:17 -0700196 <tr>
197 <td>Motorola</td>
Scott Main9fe44592011-08-26 12:42:49 -0700198 <td><code>22B8</code></td>
Scott Main69224922011-08-26 11:50:36 -0700199 </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 Main01979992010-04-05 17:42:17 -0700208 <tr>
209 <td>Nvidia</td>
Scott Main69224922011-08-26 11:50:36 -0700210 <td><code>0955</code></td>
211 </tr>
212 <tr>
213 <td>OTGV</td>
214 <td><code>2257</code></td>
215 </tr>
Scott Main01979992010-04-05 17:42:17 -0700216 <tr>
217 <td>Pantech</td>
Scott Main69224922011-08-26 11:50:36 -0700218 <td><code>10A9</code></td>
219 </tr>
220 <tr>
221 <td>Pegatron</td>
Scott Main9fe44592011-08-26 12:42:49 -0700222 <td><code>1D4D</code></td>
Scott Main69224922011-08-26 11:50:36 -0700223 </tr>
224 <tr>
225 <td>Philips</td>
226 <td><code>0471</code></td>
227 </tr>
228 <tr>
229 <td>PMC-Sierra</td>
Scott Main9fe44592011-08-26 12:42:49 -0700230 <td><code>04DA</code></td>
Scott Main69224922011-08-26 11:50:36 -0700231 </tr>
232 <tr>
233 <td>Qualcomm</td>
Scott Main9fe44592011-08-26 12:42:49 -0700234 <td><code>05C6</code></td>
Scott Main69224922011-08-26 11:50:36 -0700235 </tr>
236 <tr>
237 <td>SK Telesys</td>
Scott Main9fe44592011-08-26 12:42:49 -0700238 <td><code>1F53</code></td>
Scott Main69224922011-08-26 11:50:36 -0700239 </tr>
Scott Main01979992010-04-05 17:42:17 -0700240 <tr>
241 <td>Samsung</td>
Scott Main9fe44592011-08-26 12:42:49 -0700242 <td><code>04E8</code></td>
Scott Main69224922011-08-26 11:50:36 -0700243 </tr>
Scott Main01979992010-04-05 17:42:17 -0700244 <tr>
245 <td>Sharp</td>
Scott Main9fe44592011-08-26 12:42:49 -0700246 <td><code>04DD</code></td>
Scott Main69224922011-08-26 11:50:36 -0700247 </tr>
Scott Main01979992010-04-05 17:42:17 -0700248 <tr>
249 <td>Sony Ericsson</td>
Scott Main9fe44592011-08-26 12:42:49 -0700250 <td><code>0FCE</code></td>
Scott Main69224922011-08-26 11:50:36 -0700251 </tr>
252 <tr>
253 <td>Toshiba</td>
254 <td><code>0930</code></td>
255 </tr>
Scott Main01979992010-04-05 17:42:17 -0700256 <tr>
257 <td>ZTE</td>
Scott Main69224922011-08-26 11:50:36 -0700258 <td><code>19D2</code></td>
259 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800260</table>