blob: d22dca1fee41b7c4722510dce07102390f798f92 [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 Maina9f92a02011-10-21 14:18:16 -070033<p>If you want a SIM-unlocked phone, then you might consider the Google Nexus S. To find a place
34to purchase the Nexus S and other Android-powered devices, visit <a
35href="http://www.google.com/phone/detail/nexus-s">google.com/phone</a>.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036
Scott Main01979992010-04-05 17:42:17 -070037<p class="note"><strong>Note:</strong> When developing on a device, keep in mind that you should
38still use the <a
Scott Main69224922011-08-26 11:50:36 -070039href="{@docRoot}guide/developing/devices/emulator.html">Android emulator</a> to test your
40application
Scott Main01979992010-04-05 17:42:17 -070041on configurations that are not equivalent to those of your real device. Although the emulator
42does not allow you to test every device feature (such as the accelerometer), it does
43allow you to verify that your application functions properly on different versions of the Android
44platform, in different screen sizes and orientations, and more.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045
Scott Main79917452009-08-26 11:56:57 -070046
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047<h2 id="setting-up">Setting up a Device for Development</h2>
48
Scott Main79917452009-08-26 11:56:57 -070049<p>With an Android-powered device, you can develop and debug your Android applications just as you
Scott Main01979992010-04-05 17:42:17 -070050would on the emulator. Before you can start, there are just a few things to do:</p>
51
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052<ol>
53 <li>Declare your application as "debuggable" in your Android Manifest.
Scott Main811aca52012-02-08 13:57:53 -080054 <p>When using Eclipse, you can skip this step, because running your app directly from
55the Eclipse IDE automatically enables debugging.</p>
56 <p>In the <code>AndroidManifest.xml</code> file, add <code>android:debuggable="true"</code> to
57the <code>&lt;application></code> element.</p>
58 <p class="note"><strong>Note:</strong> If you manually enable debugging in the manifest
59 file, be sure to disable it before you build for release (your published application
60should usually <em>not</em> be debuggable).</p></li>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061 <li>Turn on "USB Debugging" on your device.
Katie McCormick31a05f32011-10-31 10:43:41 -070062 <p>On the device, go to <strong>Settings > Applications > Development</strong>
63 and enable <strong>USB debugging</strong>
64 (on an Android 4.0 device, the setting is
65located in <strong>Settings > Developer options</strong>).</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080066 </li>
Scott Main69224922011-08-26 11:50:36 -070067 <li>Set up your system to detect your device.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068 <ul>
Scott Main811aca52012-02-08 13:57:53 -080069 <li>If you're developing on Windows, you need to install a USB driver for adb. For an
70installation guide and links to OEM drivers, see the <a href="{@docRoot}sdk/oem-usb.html">OEM USB
71Drivers</a> document.</li>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072 <li>If you're developing on Mac OS X, it just works. Skip this step.</li>
Scott Maincd1b08e2011-12-27 16:22:27 -080073 <li>If you're developing on Ubuntu Linux, you need to add a
74<code>udev</code> rules file that contains a USB configuration for each type of device
Scott Main69224922011-08-26 11:50:36 -070075you want to use for development. In the rules file, each device manufacturer
76is identified by a unique vendor ID, as specified by the
77<code>ATTR{idVendor}</code> property. For a list of vendor IDs, see <a
78href="#VendorIds">USB Vendor IDs</a>, below. To set up device detection on
79Ubuntu Linux:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080
Scott Main69224922011-08-26 11:50:36 -070081 <ol type="a">
82 <li>Log in as root and create this file:
83 <code>/etc/udev/rules.d/51-android.rules</code></span>.
84 <p>Use this format to add each vendor to the file:<br/>
Scott Main9fe44592011-08-26 12:42:49 -070085 <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 -070086 <br /><br />
87
88 In this example, the vendor ID is for HTC. The <code>MODE</code>
89assignment specifies read/write permissions, and <code>GROUP</code> defines
90which Unix group owns the device node. </p>
91
92 <p class="note"><strong>Note:</strong> The rule syntax
93may vary slightly depending on your environment. Consult the <code>udev</code>
94documentation for your system as needed. For an overview of rule syntax, see
95this guide to <a
96href="http://www.reactivated.net/writing_udev_rules.html">writing udev
97rules</a>.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098 </li>
99 <li>Now execute:<br/>
Scott Main69224922011-08-26 11:50:36 -0700100 <code>chmod a+r /etc/udev/rules.d/51-android.rules</code>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101 </li>
102 </ol>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103 </li>
104 </ul>
105 </li>
106</ol>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800107
Scott Main811aca52012-02-08 13:57:53 -0800108<p>When plugged in over USB, can verify that your device is connected by executing <code>adb
Scott Main69224922011-08-26 11:50:36 -0700109devices</code> from your SDK {@code platform-tools/} directory. If connected,
110you'll see the device name listed as a "device."</p>
Scott Main01979992010-04-05 17:42:17 -0700111
Scott Main69224922011-08-26 11:50:36 -0700112<p>If using Eclipse, run or debug your application as usual. You will be
113presented with a <b>Device Chooser</b> dialog that lists the available
114emulator(s) and connected device(s). Select the device upon which you want to
115install and run the application.</p>
Scott Main01979992010-04-05 17:42:17 -0700116
Scott Main69224922011-08-26 11:50:36 -0700117<p>If using the <a href="{@docRoot}guide/developing/tools/adb.html">Android
118Debug Bridge</a> (adb), you can issue commands with the <code>-d</code> flag to
119target your connected device.</p>
Scott Main79917452009-08-26 11:56:57 -0700120
Scott Mainad68fdd2009-11-05 18:53:59 -0800121<h3 id="VendorIds">USB Vendor IDs</h3>
Scott Main69224922011-08-26 11:50:36 -0700122
123<p>This table provides a reference to the vendor IDs needed in order to add USB
124device support on Linux. The USB Vendor ID is the value given to the
125<code>ATTR{idVendor}</code> property in the rules file, as described
126above.</p>
Scott Main01979992010-04-05 17:42:17 -0700127
Scott Mainad68fdd2009-11-05 18:53:59 -0800128<table>
129 <tr>
Scott Main27854432011-03-08 16:32:09 -0800130 <th>Company</th><th>USB Vendor ID</th></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800131 <tr>
Scott Main01979992010-04-05 17:42:17 -0700132 <td>Acer</td>
Scott Main69224922011-08-26 11:50:36 -0700133 <td><code>0502</code></td>
134 </tr>
135 <tr>
136 <td>ASUS</td>
Scott Main9fe44592011-08-26 12:42:49 -0700137 <td><code>0B05</code></td>
Scott Main69224922011-08-26 11:50:36 -0700138 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800139 <tr>
Scott Main01979992010-04-05 17:42:17 -0700140 <td>Dell</td>
Scott Main9fe44592011-08-26 12:42:49 -0700141 <td><code>413C</code></td>
Scott Main69224922011-08-26 11:50:36 -0700142 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800143 <tr>
Scott Main01979992010-04-05 17:42:17 -0700144 <td>Foxconn</td>
Scott Main69224922011-08-26 11:50:36 -0700145 <td><code>0489</code></td>
146 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800147 <tr>
Scott Maincdf14452012-01-24 10:54:50 -0800148 <td>Fujitsu</td>
Scott Main4809f092012-01-24 10:58:06 -0800149 <td><code>04C5</code></td>
Scott Maincdf14452012-01-24 10:54:50 -0800150 </tr>
151 <tr>
152 <td>Fujitsu Toshiba</td>
Scott Main4809f092012-01-24 10:58:06 -0800153 <td><code>04C5</code></td>
Scott Maincdf14452012-01-24 10:54:50 -0800154 </tr>
155 <tr>
Scott Main01979992010-04-05 17:42:17 -0700156 <td>Garmin-Asus</td>
Scott Main69224922011-08-26 11:50:36 -0700157 <td><code>091E</code></td>
158 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800159 <tr>
Scott Main27854432011-03-08 16:32:09 -0800160 <td>Google</td>
Scott Main9fe44592011-08-26 12:42:49 -0700161 <td><code>18D1</code></td>
Scott Main69224922011-08-26 11:50:36 -0700162 </tr>
Scott Main27854432011-03-08 16:32:09 -0800163 <tr>
Scott Maindf440162011-12-16 12:46:31 -0800164 <td>Hisense</td>
165 <td><code>109B</code></td>
166 </tr>
167 <tr>
Scott Main01979992010-04-05 17:42:17 -0700168 <td>HTC</td>
Scott Main9fe44592011-08-26 12:42:49 -0700169 <td><code>0BB4</code></td>
Scott Main69224922011-08-26 11:50:36 -0700170 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800171 <tr>
Scott Main01979992010-04-05 17:42:17 -0700172 <td>Huawei</td>
Scott Main9fe44592011-08-26 12:42:49 -0700173 <td><code>12D1</code></td>
Scott Main69224922011-08-26 11:50:36 -0700174 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800175 <tr>
Scott Main3e485d02011-07-13 09:36:56 -0700176 <td>K-Touch</td>
Scott Main9fe44592011-08-26 12:42:49 -0700177 <td><code>24E3</code></td>
Scott Main69224922011-08-26 11:50:36 -0700178 </tr>
179 <tr>
180 <td>KT Tech</td>
181 <td><code>2116</code></td>
182 </tr>
Scott Main3e485d02011-07-13 09:36:56 -0700183 <tr>
Scott Main01979992010-04-05 17:42:17 -0700184 <td>Kyocera</td>
Scott Main69224922011-08-26 11:50:36 -0700185 <td><code>0482</code></td>
186 </tr>
Scott Main01979992010-04-05 17:42:17 -0700187 <tr>
Scott Mainea41e8d2011-06-20 15:50:12 -0700188 <td>Lenevo</td>
Scott Main69224922011-08-26 11:50:36 -0700189 <td><code>17EF</code></td>
190 </tr>
Scott Mainea41e8d2011-06-20 15:50:12 -0700191 <tr>
Scott Main01979992010-04-05 17:42:17 -0700192 <td>LG</td>
Scott Main69224922011-08-26 11:50:36 -0700193 <td><code>1004</code></td>
194 </tr>
Scott Main01979992010-04-05 17:42:17 -0700195 <tr>
196 <td>Motorola</td>
Scott Main9fe44592011-08-26 12:42:49 -0700197 <td><code>22B8</code></td>
Scott Main69224922011-08-26 11:50:36 -0700198 </tr>
199 <tr>
200 <td>NEC</td>
201 <td><code>0409</code></td>
202 </tr>
203 <tr>
204 <td>Nook</td>
205 <td><code>2080</code></td>
206 </tr>
Scott Main01979992010-04-05 17:42:17 -0700207 <tr>
208 <td>Nvidia</td>
Scott Main69224922011-08-26 11:50:36 -0700209 <td><code>0955</code></td>
210 </tr>
211 <tr>
212 <td>OTGV</td>
213 <td><code>2257</code></td>
214 </tr>
Scott Main01979992010-04-05 17:42:17 -0700215 <tr>
216 <td>Pantech</td>
Scott Main69224922011-08-26 11:50:36 -0700217 <td><code>10A9</code></td>
218 </tr>
219 <tr>
220 <td>Pegatron</td>
Scott Main9fe44592011-08-26 12:42:49 -0700221 <td><code>1D4D</code></td>
Scott Main69224922011-08-26 11:50:36 -0700222 </tr>
223 <tr>
224 <td>Philips</td>
225 <td><code>0471</code></td>
226 </tr>
227 <tr>
228 <td>PMC-Sierra</td>
Scott Main9fe44592011-08-26 12:42:49 -0700229 <td><code>04DA</code></td>
Scott Main69224922011-08-26 11:50:36 -0700230 </tr>
231 <tr>
232 <td>Qualcomm</td>
Scott Main9fe44592011-08-26 12:42:49 -0700233 <td><code>05C6</code></td>
Scott Main69224922011-08-26 11:50:36 -0700234 </tr>
235 <tr>
236 <td>SK Telesys</td>
Scott Main9fe44592011-08-26 12:42:49 -0700237 <td><code>1F53</code></td>
Scott Main69224922011-08-26 11:50:36 -0700238 </tr>
Scott Main01979992010-04-05 17:42:17 -0700239 <tr>
240 <td>Samsung</td>
Scott Main9fe44592011-08-26 12:42:49 -0700241 <td><code>04E8</code></td>
Scott Main69224922011-08-26 11:50:36 -0700242 </tr>
Scott Main01979992010-04-05 17:42:17 -0700243 <tr>
244 <td>Sharp</td>
Scott Main9fe44592011-08-26 12:42:49 -0700245 <td><code>04DD</code></td>
Scott Main69224922011-08-26 11:50:36 -0700246 </tr>
Scott Main01979992010-04-05 17:42:17 -0700247 <tr>
Scott Mained4d1f72012-02-06 13:01:44 -0800248 <td>Sony</td>
249 <td><code>054C</code></td>
250 </tr>
251 <tr>
Scott Main01979992010-04-05 17:42:17 -0700252 <td>Sony Ericsson</td>
Scott Main9fe44592011-08-26 12:42:49 -0700253 <td><code>0FCE</code></td>
Scott Main69224922011-08-26 11:50:36 -0700254 </tr>
255 <tr>
Scott Mainc8810c22012-01-04 11:47:18 -0800256 <td>Teleepoch</td>
257 <td><code>2340</code></td>
258 </tr>
259 <tr>
Scott Main69224922011-08-26 11:50:36 -0700260 <td>Toshiba</td>
261 <td><code>0930</code></td>
262 </tr>
Scott Main01979992010-04-05 17:42:17 -0700263 <tr>
264 <td>ZTE</td>
Scott Main69224922011-08-26 11:50:36 -0700265 <td><code>19D2</code></td>
266 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800267</table>