Home | History | Annotate | Download | only in tools
      1 page.title=Using Hardware Devices
      2 @jd:body
      3 
      4 <div id="qv-wrapper">
      5 <div id="qv">
      6   <h2>In this document</h2>
      7   <ol>
      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 href="{@docRoot}sdk/win-usb.html">Google USB Driver</a></li>
     17     <li><a href="{@docRoot}tools/extras/oem-usb.html">OEM USB Drivers</a></li>
     18   </ol>
     19 </div>
     20 </div>
     21 
     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>
     25 
     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
     29 device directly from Eclipse or from the command line with ADB. If
     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>
     32 
     33 <p>If you want a SIM-unlocked phone, then you might consider the Google Nexus S. To find a place
     34 to purchase the Nexus S and other Android-powered devices, visit <a
     35 href="http://www.google.com/phone/detail/nexus-s">google.com/phone</a>.</p>
     36 
     37 <p class="note"><strong>Note:</strong> When developing on a device, keep in mind that you should
     38 still use the <a
     39 href="{@docRoot}tools/devices/emulator.html">Android emulator</a> to test your
     40 application
     41 on configurations that are not equivalent to those of your real device. Although the emulator
     42 does not allow you to test every device feature (such as the accelerometer), it does
     43 allow you to verify that your application functions properly on different versions of the Android
     44 platform, in different screen sizes and orientations, and more.</p>
     45 
     46 
     47 <h2 id="setting-up">Setting up a Device for Development</h2>
     48 
     49 <p>With an Android-powered device, you can develop and debug your Android applications just as you
     50 would on the emulator. Before you can start, there are just a few things to do:</p>
     51 
     52 <ol>
     53   <li>Declare your application as "debuggable" in your Android Manifest.
     54     <p>When using Eclipse, you can skip this step, because running your app directly from
     55 the Eclipse IDE automatically enables debugging.</p>
     56     <p>In the <code>AndroidManifest.xml</code> file, add <code>android:debuggable="true"</code> to
     57 the <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
     60 should usually <em>not</em> be debuggable).</p></li>
     61   <li>Turn on "USB Debugging" on your device.
     62     <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 
     65 located in <strong>Settings > Developer options</strong>).</p>
     66   </li>
     67   <li>Set up your system to detect your device.
     68     <ul>
     69       <li>If you're developing on Windows, you need to install a USB driver for adb. For an
     70 installation guide and links to OEM drivers, see the <a href="{@docRoot}tools/extras/oem-usb.html">OEM USB
     71 Drivers</a> document.</li>
     72       <li>If you're developing on Mac OS X, it just works. Skip this step.</li>
     73       <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
     75 you want to use for development. In the rules file, each device manufacturer
     76 is identified by a unique vendor ID, as specified by the
     77 <code>ATTR{idVendor}</code> property. For a list of vendor IDs, see  <a
     78 href="#VendorIds">USB Vendor IDs</a>, below. To set up device detection on
     79 Ubuntu Linux:
     80 
     81         <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/>
     85               <code>SUBSYSTEM==&quot;usb&quot;, ATTR{idVendor}==&quot;0bb4&quot;, MODE=&quot;0666&quot;, GROUP=&quot;plugdev&quot;</code>
     86               <br /><br />
     87               
     88               In this example, the vendor ID is for HTC. The <code>MODE</code>
     89 assignment specifies read/write permissions, and <code>GROUP</code> defines
     90 which Unix group  owns the device node. </p>
     91             
     92             <p class="note"><strong>Note:</strong> The rule syntax
     93 may vary slightly depending on your  environment. Consult the <code>udev</code>
     94 documentation for your system as needed. For an overview of rule syntax, see
     95 this guide to <a
     96 href="http://www.reactivated.net/writing_udev_rules.html">writing udev
     97 rules</a>.</p>
     98           </li>
     99           <li>Now execute:<br/>
    100             <code>chmod a+r /etc/udev/rules.d/51-android.rules</code>
    101           </li>
    102         </ol>
    103       </li>
    104     </ul>
    105   </li>
    106 </ol>
    107 
    108 <p>When plugged in over USB, can verify that your device is connected by executing <code>adb
    109 devices</code> from your SDK {@code platform-tools/} directory. If connected,
    110 you'll see the device name listed as a "device."</p>
    111 
    112 <p>If using Eclipse, run or debug your application as usual. You will be
    113 presented with a <b>Device Chooser</b> dialog that lists the available
    114 emulator(s) and connected device(s). Select the device upon which you want to
    115 install and run the application.</p>
    116 
    117 <p>If using the <a href="{@docRoot}tools/help/adb.html">Android
    118 Debug Bridge</a> (adb), you can issue commands with the <code>-d</code> flag to
    119 target your connected device.</p>
    120 
    121 <h3 id="VendorIds">USB Vendor IDs</h3>
    122 
    123 <p>This table provides a reference to the vendor IDs needed in order to add USB
    124 device 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 
    126 above.</p>
    127 
    128 <table>
    129   <tr>
    130     <th>Company</th><th>USB Vendor ID</th></tr>
    131   <tr>
    132     <td>Acer</td>
    133     <td><code>0502</code></td>
    134   </tr>
    135   <tr>
    136     <td>ASUS</td>
    137     <td><code>0b05</code></td>
    138   </tr>
    139   <tr>
    140     <td>Dell</td>
    141     <td><code>413c</code></td>
    142   </tr>
    143   <tr>
    144     <td>Foxconn</td>
    145     <td><code>0489</code></td>
    146   </tr>
    147   <tr>
    148     <td>Fujitsu</td>
    149     <td><code>04c5</code></td>
    150   </tr>
    151   <tr>
    152     <td>Fujitsu Toshiba</td>
    153     <td><code>04c5</code></td>
    154   </tr>
    155   <tr>
    156     <td>Garmin-Asus</td>
    157     <td><code>091e</code></td>
    158   </tr>
    159   <tr>
    160     <td>Google</td>
    161     <td><code>18d1</code></td>
    162   </tr>
    163   <tr>
    164     <td>Hisense</td>
    165     <td><code>109b</code></td>
    166   </tr>
    167   <tr>
    168     <td>HTC</td>
    169     <td><code>0bb4</code></td>
    170   </tr>
    171   <tr>
    172     <td>Huawei</td>
    173     <td><code>12d1</code></td>
    174   </tr>
    175   <tr>
    176     <td>K-Touch</td>
    177     <td><code>24e3</code></td>
    178   </tr>
    179   <tr>
    180     <td>KT Tech</td>
    181     <td><code>2116</code></td>
    182   </tr>
    183   <tr>
    184     <td>Kyocera</td>
    185     <td><code>0482</code></td>
    186   </tr>
    187   <tr>
    188     <td>Lenovo</td>
    189     <td><code>17ef</code></td>
    190   </tr>
    191   <tr>
    192     <td>LG</td>
    193     <td><code>1004</code></td>
    194   </tr>
    195   <tr>
    196     <td>Motorola</td>
    197     <td><code>22b8</code></td>
    198   </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>
    207   <tr>
    208     <td>Nvidia</td>
    209     <td><code>0955</code></td>
    210   </tr>
    211   <tr>
    212     <td>OTGV</td>
    213     <td><code>2257</code></td>
    214   </tr>
    215   <tr>
    216     <td>Pantech</td>
    217     <td><code>10a9</code></td>
    218   </tr>
    219   <tr>
    220     <td>Pegatron</td>
    221     <td><code>1d4d</code></td>
    222   </tr>
    223   <tr>
    224     <td>Philips</td>
    225     <td><code>0471</code></td>
    226   </tr>
    227   <tr>
    228     <td>PMC-Sierra</td>
    229     <td><code>04da</code></td>
    230   </tr>
    231   <tr>
    232     <td>Qualcomm</td>
    233     <td><code>05c6</code></td>
    234   </tr>
    235   <tr>
    236     <td>SK Telesys</td>
    237     <td><code>1f53</code></td>
    238   </tr>
    239   <tr>
    240     <td>Samsung</td>
    241     <td><code>04e8</code></td>
    242   </tr>
    243   <tr>
    244     <td>Sharp</td>
    245     <td><code>04dd</code></td>
    246   </tr>
    247   <tr>
    248     <td>Sony</td>
    249     <td><code>054c</code></td>
    250   </tr>
    251   <tr>
    252     <td>Sony Ericsson</td>
    253     <td><code>0fce</code></td>
    254   </tr>
    255   <tr>
    256     <td>Teleepoch</td>
    257     <td><code>2340</code></td>
    258   </tr>
    259   <tr>
    260     <td>Toshiba</td>
    261     <td><code>0930</code></td>
    262   </tr>
    263   <tr>
    264     <td>ZTE</td>
    265     <td><code>19d2</code></td>
    266   </tr>
    267 </table>
    268