blob: bde170e09c05558f0d33b372793cde1ca330c555 [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
Robert Ly67c2d972011-01-05 00:54:41 -080044href="{@docRoot}guide/developing/devices/emulator.html">Android emulator</a> to test your application
Scott Main01979992010-04-05 17:42:17 -070045on configurations that are not equivalent to those of your real device. Although the emulator
46does not allow you to test every device feature (such as the accelerometer), it does
47allow you to verify that your application functions properly on different versions of the Android
48platform, in different screen sizes and orientations, and more.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049
Scott Main79917452009-08-26 11:56:57 -070050
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051<h2 id="setting-up">Setting up a Device for Development</h2>
52
Scott Main79917452009-08-26 11:56:57 -070053<p>With an Android-powered device, you can develop and debug your Android applications just as you
Scott Main01979992010-04-05 17:42:17 -070054would on the emulator. Before you can start, there are just a few things to do:</p>
55
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056<ol>
57 <li>Declare your application as "debuggable" in your Android Manifest.
58 <p>In Eclipse, you can do this from the <b>Application</b> tab when viewing the Manifest
59 (on the right side, set <b>Debuggable</b> to <em>true</em>). Otherwise, in the <code>AndroidManifest.xml</code>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060 file, add <code>android:debuggable="true"</code> to the <code>&lt;application></code> element.</p>
61 </li>
62 <li>Turn on "USB Debugging" on your device.
63 <p>On the device, go to the home screen, press <b>MENU</b>, select <b>Applications</b> > <b>Development</b>,
64 then enable <b>USB debugging</b>.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080065 </li>
66 <li>Setup your system to detect your device.
67 <ul>
Scott Mainad68fdd2009-11-05 18:53:59 -080068 <li>If you're developing on Windows, you need to install a USB driver
Scott Main0f805632011-01-07 10:45:03 -080069 for adb. If you're using an Android Developer Phone (ADP), Nexus One, or Nexus S,
70 see the <a href="{@docRoot}sdk/win-usb.html">Google Windows USB
71 Driver</a>. Otherwise, you can find a link to the appropriate OEM driver in the
72 <a href="{@docRoot}sdk/oem-usb.html">OEM USB Drivers</a> document.</li>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073 <li>If you're developing on Mac OS X, it just works. Skip this step.</li>
Scott Mainad68fdd2009-11-05 18:53:59 -080074 <li>If you're developing on Ubuntu Linux, you need to add a rules file
75that contains a USB configuration for each type of device you want to use for
76development. Each device manufacturer uses a different vendor ID. The
77example rules files below show how to add an entry for a single vendor ID
78(the HTC vendor ID). In order to support more devices, you will need additional
79lines of the same format that provide a different value for the
80<code>SYSFS{idVendor}</code> property. For other IDs, see the table of <a
81href="#VendorIds">USB Vendor IDs</a>, below.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080082 <ol>
Scott Mainad68fdd2009-11-05 18:53:59 -080083 <li>Log in as root and create this file:
84 <code>/etc/udev/rules.d/51-android.rules</code>.
85 <p>For Gusty/Hardy, edit the file to read:<br/>
86 <code>SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4",
87 MODE="0666"</code></p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088
Scott Mainad68fdd2009-11-05 18:53:59 -080089 <p>For Dapper, edit the file to read:<br/>
90 <code>SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4",
91 MODE="0666"</code></p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092 </li>
93 <li>Now execute:<br/>
Scott Main87b90552009-08-26 15:18:14 -070094 <code>chmod a+r /etc/udev/rules.d/51-android.rules</code>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080095 </li>
96 </ol>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 </li>
98 </ul>
99 </li>
100</ol>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101
Scott Main01979992010-04-05 17:42:17 -0700102<p>You can verify that your device is connected by executing <code>adb devices</code> from your
Scott Main3165bbb2010-12-16 10:26:23 -0800103SDK {@code platform-tools/} directory. If connected, you'll see the device name listed as a
104"device."</p>
Scott Main01979992010-04-05 17:42:17 -0700105
106<p>If using Eclipse, run or debug as usual. You will be presented
107with a <b>Device Chooser</b> dialog that lists the available emulator(s) and connected device(s).
108Select the device upon which you want to install and run the application.</p>
109
110<p>If using the <a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a> (adb),
Scott Mainad68fdd2009-11-05 18:53:59 -0800111you can issue commands with the <code>-d</code> flag to target your
112connected device.</p>
Scott Main79917452009-08-26 11:56:57 -0700113
114
Scott Mainad68fdd2009-11-05 18:53:59 -0800115<h3 id="VendorIds">USB Vendor IDs</h3>
116<p>This table provides a reference to the vendor IDs needed in order to add
Scott Main01979992010-04-05 17:42:17 -0700117USB device support on Linux. The USB Vendor ID is the value given to the
118<code>SYSFS{idVendor}</code> property in the rules file, as described in step 3, above.</p>
119
Scott Mainad68fdd2009-11-05 18:53:59 -0800120<table>
121 <tr>
Scott Main27854432011-03-08 16:32:09 -0800122 <th>Company</th><th>USB Vendor ID</th></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800123 <tr>
Scott Main01979992010-04-05 17:42:17 -0700124 <td>Acer</td>
125 <td><code>0502</code></td></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800126 <tr>
Scott Main01979992010-04-05 17:42:17 -0700127 <td>Dell</td>
128 <td><code>413c</code></td></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800129 <tr>
Scott Main01979992010-04-05 17:42:17 -0700130 <td>Foxconn</td>
131 <td><code>0489</code></td></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800132 <tr>
Scott Main01979992010-04-05 17:42:17 -0700133 <td>Garmin-Asus</td>
134 <td><code>091E</code></td></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800135 <tr>
Scott Main27854432011-03-08 16:32:09 -0800136 <td>Google</td>
137 <td><code>18d1</code></td></tr>
138 <tr>
Scott Main01979992010-04-05 17:42:17 -0700139 <td>HTC</td>
140 <td><code>0bb4</code></td></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800141 <tr>
Scott Main01979992010-04-05 17:42:17 -0700142 <td>Huawei</td>
143 <td><code>12d1</code></td></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800144 <tr>
Scott Main3e485d02011-07-13 09:36:56 -0700145 <td>K-Touch</td>
146 <td><code>24e3</code></td></tr>
147 <tr>
Scott Main01979992010-04-05 17:42:17 -0700148 <td>Kyocera</td>
149 <td><code>0482</code></td></tr>
150 <tr>
Scott Mainea41e8d2011-06-20 15:50:12 -0700151 <td>Lenevo</td>
152 <td><code>17EF</code></td></tr>
153 <tr>
Scott Main01979992010-04-05 17:42:17 -0700154 <td>LG</td>
155 <td><code>1004</code></td></tr>
156 <tr>
157 <td>Motorola</td>
158 <td><code>22b8</code></td></tr>
159 <tr>
160 <td>Nvidia</td>
161 <td><code>0955</code></td></tr>
162 <tr>
163 <td>Pantech</td>
164 <td><code>10A9</code></td></tr>
165 <tr>
166 <td>Samsung</td>
167 <td><code>04e8</code></td></tr>
168 <tr>
169 <td>Sharp</td>
170 <td><code>04dd</code></td></tr>
171 <tr>
172 <td>Sony Ericsson</td>
173 <td><code>0fce</code></td></tr>
174 <tr>
175 <td>ZTE</td>
176 <td><code>19D2</code></td></tr>
Scott Mainad68fdd2009-11-05 18:53:59 -0800177</table>