blob: 62ebfeee76f1ec303d3eecd5b370e06ef144f67f [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.
54 <p>In Eclipse, you can do this from the <b>Application</b> tab when viewing the Manifest
Scott Main69224922011-08-26 11:50:36 -070055 (on the right side, set <b>Debuggable</b> to <em>true</em>). Otherwise, in the
56<code>AndroidManifest.xml</code>
57 file, add <code>android:debuggable="true"</code> to the <code>&lt;application></code>
58element.</p>
59 </li>
60 <li>Set up your device to allow installation of non-Market applications. <p>On
Katie McCormick31a05f32011-10-31 10:43:41 -070061the device, go to <strong>Settings > Applications</strong> and enable
Scott Main69224922011-08-26 11:50:36 -070062
Katie McCormick31a05f32011-10-31 10:43:41 -070063<strong>Unknown sources</strong> (on an Android 4.0 device, the setting is
64located in <strong>Settings > Security</strong>).</p>
Scott Main69224922011-08-26 11:50:36 -070065
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080066 </li>
67 <li>Turn on "USB Debugging" on your device.
Katie McCormick31a05f32011-10-31 10:43:41 -070068 <p>On the device, go to <strong>Settings > Applications > Development</strong>
69 and enable <strong>USB debugging</strong>
70 (on an Android 4.0 device, the setting is
71located in <strong>Settings > Developer options</strong>).</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072 </li>
Scott Main69224922011-08-26 11:50:36 -070073 <li>Set up your system to detect your device.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074 <ul>
Scott Mainad68fdd2009-11-05 18:53:59 -080075 <li>If you're developing on Windows, you need to install a USB driver
Scott Main0f805632011-01-07 10:45:03 -080076 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>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080 <li>If you're developing on Mac OS X, it just works. Skip this step.</li>
Scott Main69224922011-08-26 11:50:36 -070081
82 <li>If you're developing on Ubuntu Linux, you need to add a <a
83href="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html">
84<code>udev</code></a>
85rules file that contains a USB configuration for each type of device
86you want to use for development. In the rules file, each device manufacturer
87is identified by a unique vendor ID, as specified by the
88<code>ATTR{idVendor}</code> property. For a list of vendor IDs, see <a
89href="#VendorIds">USB Vendor IDs</a>, below. To set up device detection on
90Ubuntu Linux:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080091
Scott Main69224922011-08-26 11:50:36 -070092 <ol type="a">
93 <li>Log in as root and create this file:
94 <code>/etc/udev/rules.d/51-android.rules</code></span>.
95 <p>Use this format to add each vendor to the file:<br/>
Scott Main9fe44592011-08-26 12:42:49 -070096 <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 -070097 <br /><br />
98
99 In this example, the vendor ID is for HTC. The <code>MODE</code>
100assignment specifies read/write permissions, and <code>GROUP</code> defines
101which Unix group owns the device node. </p>
102
103 <p class="note"><strong>Note:</strong> The rule syntax
104may vary slightly depending on your environment. Consult the <code>udev</code>
105documentation for your system as needed. For an overview of rule syntax, see
106this guide to <a
107href="http://www.reactivated.net/writing_udev_rules.html">writing udev
108rules</a>.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109 </li>
110 <li>Now execute:<br/>
Scott Main69224922011-08-26 11:50:36 -0700111 <code>chmod a+r /etc/udev/rules.d/51-android.rules</code>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800112 </li>
113 </ol>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800114 </li>
115 </ul>
116 </li>
117</ol>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118
Scott Main69224922011-08-26 11:50:36 -0700119<p>You can verify that your device is connected by executing <code>adb
120devices</code> from your SDK {@code platform-tools/} directory. If connected,
121you'll see the device name listed as a "device."</p>
Scott Main01979992010-04-05 17:42:17 -0700122
Scott Main69224922011-08-26 11:50:36 -0700123<p>If using Eclipse, run or debug your application as usual. You will be
124presented with a <b>Device Chooser</b> dialog that lists the available
125emulator(s) and connected device(s). Select the device upon which you want to
126install and run the application.</p>
Scott Main01979992010-04-05 17:42:17 -0700127
Scott Main69224922011-08-26 11:50:36 -0700128<p>If using the <a href="{@docRoot}guide/developing/tools/adb.html">Android
129Debug Bridge</a> (adb), you can issue commands with the <code>-d</code> flag to
130target your connected device.</p>
Scott Main79917452009-08-26 11:56:57 -0700131
Scott Mainad68fdd2009-11-05 18:53:59 -0800132<h3 id="VendorIds">USB Vendor IDs</h3>
Scott Main69224922011-08-26 11:50:36 -0700133
134<p>This table provides a reference to the vendor IDs needed in order to add USB
135device support on Linux. The USB Vendor ID is the value given to the
136<code>ATTR{idVendor}</code> property in the rules file, as described
137above.</p>
Scott Main01979992010-04-05 17:42:17 -0700138
Scott Mainad68fdd2009-11-05 18:53:59 -0800139<table>
140 <tr>
Scott Main27854432011-03-08 16:32:09 -0800141 <th>Company</th><th>USB Vendor ID</th></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800142 <tr>
Scott Main01979992010-04-05 17:42:17 -0700143 <td>Acer</td>
Scott Main69224922011-08-26 11:50:36 -0700144 <td><code>0502</code></td>
145 </tr>
146 <tr>
147 <td>ASUS</td>
Scott Main9fe44592011-08-26 12:42:49 -0700148 <td><code>0B05</code></td>
Scott Main69224922011-08-26 11:50:36 -0700149 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800150 <tr>
Scott Main01979992010-04-05 17:42:17 -0700151 <td>Dell</td>
Scott Main9fe44592011-08-26 12:42:49 -0700152 <td><code>413C</code></td>
Scott Main69224922011-08-26 11:50:36 -0700153 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800154 <tr>
Scott Main01979992010-04-05 17:42:17 -0700155 <td>Foxconn</td>
Scott Main69224922011-08-26 11:50:36 -0700156 <td><code>0489</code></td>
157 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800158 <tr>
Scott Main01979992010-04-05 17:42:17 -0700159 <td>Garmin-Asus</td>
Scott Main69224922011-08-26 11:50:36 -0700160 <td><code>091E</code></td>
161 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800162 <tr>
Scott Main27854432011-03-08 16:32:09 -0800163 <td>Google</td>
Scott Main9fe44592011-08-26 12:42:49 -0700164 <td><code>18D1</code></td>
Scott Main69224922011-08-26 11:50:36 -0700165 </tr>
Scott Main27854432011-03-08 16:32:09 -0800166 <tr>
Scott Maindf440162011-12-16 12:46:31 -0800167 <td>Hisense</td>
168 <td><code>109B</code></td>
169 </tr>
170 <tr>
Scott Main01979992010-04-05 17:42:17 -0700171 <td>HTC</td>
Scott Main9fe44592011-08-26 12:42:49 -0700172 <td><code>0BB4</code></td>
Scott Main69224922011-08-26 11:50:36 -0700173 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800174 <tr>
Scott Main01979992010-04-05 17:42:17 -0700175 <td>Huawei</td>
Scott Main9fe44592011-08-26 12:42:49 -0700176 <td><code>12D1</code></td>
Scott Main69224922011-08-26 11:50:36 -0700177 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800178 <tr>
Scott Main3e485d02011-07-13 09:36:56 -0700179 <td>K-Touch</td>
Scott Main9fe44592011-08-26 12:42:49 -0700180 <td><code>24E3</code></td>
Scott Main69224922011-08-26 11:50:36 -0700181 </tr>
182 <tr>
183 <td>KT Tech</td>
184 <td><code>2116</code></td>
185 </tr>
Scott Main3e485d02011-07-13 09:36:56 -0700186 <tr>
Scott Main01979992010-04-05 17:42:17 -0700187 <td>Kyocera</td>
Scott Main69224922011-08-26 11:50:36 -0700188 <td><code>0482</code></td>
189 </tr>
Scott Main01979992010-04-05 17:42:17 -0700190 <tr>
Scott Mainea41e8d2011-06-20 15:50:12 -0700191 <td>Lenevo</td>
Scott Main69224922011-08-26 11:50:36 -0700192 <td><code>17EF</code></td>
193 </tr>
Scott Mainea41e8d2011-06-20 15:50:12 -0700194 <tr>
Scott Main01979992010-04-05 17:42:17 -0700195 <td>LG</td>
Scott Main69224922011-08-26 11:50:36 -0700196 <td><code>1004</code></td>
197 </tr>
Scott Main01979992010-04-05 17:42:17 -0700198 <tr>
199 <td>Motorola</td>
Scott Main9fe44592011-08-26 12:42:49 -0700200 <td><code>22B8</code></td>
Scott Main69224922011-08-26 11:50:36 -0700201 </tr>
202 <tr>
203 <td>NEC</td>
204 <td><code>0409</code></td>
205 </tr>
206 <tr>
207 <td>Nook</td>
208 <td><code>2080</code></td>
209 </tr>
Scott Main01979992010-04-05 17:42:17 -0700210 <tr>
211 <td>Nvidia</td>
Scott Main69224922011-08-26 11:50:36 -0700212 <td><code>0955</code></td>
213 </tr>
214 <tr>
215 <td>OTGV</td>
216 <td><code>2257</code></td>
217 </tr>
Scott Main01979992010-04-05 17:42:17 -0700218 <tr>
219 <td>Pantech</td>
Scott Main69224922011-08-26 11:50:36 -0700220 <td><code>10A9</code></td>
221 </tr>
222 <tr>
223 <td>Pegatron</td>
Scott Main9fe44592011-08-26 12:42:49 -0700224 <td><code>1D4D</code></td>
Scott Main69224922011-08-26 11:50:36 -0700225 </tr>
226 <tr>
227 <td>Philips</td>
228 <td><code>0471</code></td>
229 </tr>
230 <tr>
231 <td>PMC-Sierra</td>
Scott Main9fe44592011-08-26 12:42:49 -0700232 <td><code>04DA</code></td>
Scott Main69224922011-08-26 11:50:36 -0700233 </tr>
234 <tr>
235 <td>Qualcomm</td>
Scott Main9fe44592011-08-26 12:42:49 -0700236 <td><code>05C6</code></td>
Scott Main69224922011-08-26 11:50:36 -0700237 </tr>
238 <tr>
239 <td>SK Telesys</td>
Scott Main9fe44592011-08-26 12:42:49 -0700240 <td><code>1F53</code></td>
Scott Main69224922011-08-26 11:50:36 -0700241 </tr>
Scott Main01979992010-04-05 17:42:17 -0700242 <tr>
243 <td>Samsung</td>
Scott Main9fe44592011-08-26 12:42:49 -0700244 <td><code>04E8</code></td>
Scott Main69224922011-08-26 11:50:36 -0700245 </tr>
Scott Main01979992010-04-05 17:42:17 -0700246 <tr>
247 <td>Sharp</td>
Scott Main9fe44592011-08-26 12:42:49 -0700248 <td><code>04DD</code></td>
Scott Main69224922011-08-26 11:50:36 -0700249 </tr>
Scott Main01979992010-04-05 17:42:17 -0700250 <tr>
251 <td>Sony Ericsson</td>
Scott Main9fe44592011-08-26 12:42:49 -0700252 <td><code>0FCE</code></td>
Scott Main69224922011-08-26 11:50:36 -0700253 </tr>
254 <tr>
Scott Mainc8810c22012-01-04 11:47:18 -0800255 <td>Teleepoch</td>
256 <td><code>2340</code></td>
257 </tr>
258 <tr>
Scott Main69224922011-08-26 11:50:36 -0700259 <td>Toshiba</td>
260 <td><code>0930</code></td>
261 </tr>
Scott Main01979992010-04-05 17:42:17 -0700262 <tr>
263 <td>ZTE</td>
Scott Main69224922011-08-26 11:50:36 -0700264 <td><code>19D2</code></td>
265 </tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800266</table>