| Robert Ly | fd5a0e3 | 2010-12-29 16:16:23 -0800 | [diff] [blame] | 1 | page.title=Connecting 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> |
| 16 | <li><a |
| 17 | href="{@docRoot}sdk/win-usb.html">USB Driver for Windows</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 |
| Robert Ly | 67c2d97 | 2011-01-05 00:54:41 -0800 | [diff] [blame] | 44 | href="{@docRoot}guide/developing/devices/emulator.html">Android emulator</a> to test your application |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 45 | on configurations that are not equivalent to those of your real device. Although the emulator |
| 46 | does not allow you to test every device feature (such as the accelerometer), it does |
| 47 | allow you to verify that your application functions properly on different versions of the Android |
| 48 | 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] | 49 | |
| Scott Main | 7991745 | 2009-08-26 11:56:57 -0700 | [diff] [blame] | 50 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | <h2 id="setting-up">Setting up a Device for Development</h2> |
| 52 | |
| Scott Main | 7991745 | 2009-08-26 11:56:57 -0700 | [diff] [blame] | 53 | <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] | 54 | would on the emulator. Before you can start, there are just a few things to do:</p> |
| 55 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | <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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | file, add <code>android:debuggable="true"</code> to the <code><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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | </li> |
| 66 | <li>Setup your system to detect your device. |
| 67 | <ul> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 68 | <li>If you're developing on Windows, you need to install a USB driver |
| 69 | for adb. See the <a href="{@docRoot}sdk/win-usb.html">Windows USB |
| 70 | Driver</a> documentation.</li> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | <li>If you're developing on Mac OS X, it just works. Skip this step.</li> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 72 | <li>If you're developing on Ubuntu Linux, you need to add a rules file |
| 73 | that contains a USB configuration for each type of device you want to use for |
| 74 | development. Each device manufacturer uses a different vendor ID. The |
| 75 | example rules files below show how to add an entry for a single vendor ID |
| 76 | (the HTC vendor ID). In order to support more devices, you will need additional |
| 77 | lines of the same format that provide a different value for the |
| 78 | <code>SYSFS{idVendor}</code> property. For other IDs, see the table of <a |
| 79 | href="#VendorIds">USB Vendor IDs</a>, below. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | <ol> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 81 | <li>Log in as root and create this file: |
| 82 | <code>/etc/udev/rules.d/51-android.rules</code>. |
| 83 | <p>For Gusty/Hardy, edit the file to read:<br/> |
| 84 | <code>SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", |
| 85 | MODE="0666"</code></p> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 87 | <p>For Dapper, edit the file to read:<br/> |
| 88 | <code>SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", |
| 89 | MODE="0666"</code></p> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | </li> |
| 91 | <li>Now execute:<br/> |
| Scott Main | 87b9055 | 2009-08-26 15:18:14 -0700 | [diff] [blame] | 92 | <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] | 93 | </li> |
| 94 | </ol> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | </li> |
| 96 | </ul> |
| 97 | </li> |
| 98 | </ol> |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 100 | <p>You can verify that your device is connected by executing <code>adb devices</code> from your |
| Scott Main | 3165bbb | 2010-12-16 10:26:23 -0800 | [diff] [blame] | 101 | SDK {@code platform-tools/} directory. If connected, you'll see the device name listed as a |
| 102 | "device."</p> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 103 | |
| 104 | <p>If using Eclipse, run or debug as usual. You will be presented |
| 105 | with a <b>Device Chooser</b> dialog that lists the available emulator(s) and connected device(s). |
| 106 | Select the device upon which you want to install and run the application.</p> |
| 107 | |
| 108 | <p>If using the <a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a> (adb), |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 109 | you can issue commands with the <code>-d</code> flag to target your |
| 110 | connected device.</p> |
| Scott Main | 7991745 | 2009-08-26 11:56:57 -0700 | [diff] [blame] | 111 | |
| 112 | |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 113 | <h3 id="VendorIds">USB Vendor IDs</h3> |
| 114 | <p>This table provides a reference to the vendor IDs needed in order to add |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 115 | USB device support on Linux. The USB Vendor ID is the value given to the |
| 116 | <code>SYSFS{idVendor}</code> property in the rules file, as described in step 3, above.</p> |
| 117 | |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 118 | <table> |
| 119 | <tr> |
| 120 | <th>Manufacturer</th><th>USB Vendor ID</th></tr> |
| 121 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 122 | <td>Acer</td> |
| 123 | <td><code>0502</code></td></tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 124 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 125 | <td>Dell</td> |
| 126 | <td><code>413c</code></td></tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 127 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 128 | <td>Foxconn</td> |
| 129 | <td><code>0489</code></td></tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 130 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 131 | <td>Garmin-Asus</td> |
| 132 | <td><code>091E</code></td></tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 133 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 134 | <td>HTC</td> |
| 135 | <td><code>0bb4</code></td></tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 136 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 137 | <td>Huawei</td> |
| 138 | <td><code>12d1</code></td></tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 139 | <tr> |
| Scott Main | 0197999 | 2010-04-05 17:42:17 -0700 | [diff] [blame] | 140 | <td>Kyocera</td> |
| 141 | <td><code>0482</code></td></tr> |
| 142 | <tr> |
| 143 | <td>LG</td> |
| 144 | <td><code>1004</code></td></tr> |
| 145 | <tr> |
| 146 | <td>Motorola</td> |
| 147 | <td><code>22b8</code></td></tr> |
| 148 | <tr> |
| 149 | <td>Nvidia</td> |
| 150 | <td><code>0955</code></td></tr> |
| 151 | <tr> |
| 152 | <td>Pantech</td> |
| 153 | <td><code>10A9</code></td></tr> |
| 154 | <tr> |
| 155 | <td>Samsung</td> |
| 156 | <td><code>04e8</code></td></tr> |
| 157 | <tr> |
| 158 | <td>Sharp</td> |
| 159 | <td><code>04dd</code></td></tr> |
| 160 | <tr> |
| 161 | <td>Sony Ericsson</td> |
| 162 | <td><code>0fce</code></td></tr> |
| 163 | <tr> |
| 164 | <td>ZTE</td> |
| 165 | <td><code>19D2</code></td></tr> |
| Scott Main | ad68fdd | 2009-11-05 18:53:59 -0800 | [diff] [blame] | 166 | </table> |