2011-02-08 15:04:42 -08:00
|
|
|
page.title=Using Hardware Devices
|
2009-03-03 19:31:44 -08:00
|
|
|
@jd:body
|
|
|
|
|
|
|
|
<div id="qv-wrapper">
|
|
|
|
<div id="qv">
|
|
|
|
<h2>In this document</h2>
|
|
|
|
<ol>
|
2009-11-05 18:53:59 -08:00
|
|
|
<li><a href="#setting-up">Setting up a Device for Development</a>
|
|
|
|
<ol>
|
|
|
|
<li><a href="#VendorIds">USB Vendor IDs</a></li>
|
|
|
|
</ol>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
<h2>See also</h2>
|
|
|
|
<ol>
|
2011-01-07 10:45:03 -08:00
|
|
|
<li><a href="{@docRoot}sdk/win-usb.html">Google USB Driver</a></li>
|
|
|
|
<li><a href="{@docRoot}sdk/oem-usb.html">OEM USB Drivers</a></li>
|
2009-03-03 19:31:44 -08:00
|
|
|
</ol>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2010-04-05 17:42:17 -07:00
|
|
|
<p>When building a mobile application, it's important that you always test your application on a
|
|
|
|
real device before releasing it to users. This page describes how to set up your development
|
|
|
|
environment and Android-powered device for testing and debugging on the device.</p>
|
|
|
|
|
|
|
|
<p>You can use any Android-powered device as an environment for running,
|
|
|
|
debugging, and testing your applications. The tools included in the SDK make it easy to install and
|
|
|
|
run your application on the device each time you compile. You can install your application on the
|
2010-12-22 09:46:12 -08:00
|
|
|
device directly from Eclipse or from the command line with ADB. If
|
2010-04-05 17:42:17 -07:00
|
|
|
you don't yet have a device, check with the service providers in your area to determine which
|
|
|
|
Android-powered devices are available.</p>
|
|
|
|
|
|
|
|
<p>If you want a SIM-unlocked phone, then you might consider either an Android Dev Phone or the
|
2011-01-07 13:46:42 -08:00
|
|
|
Google Nexus S. These are SIM-unlocked so that you can use them on any GSM network using a SIM
|
2010-04-05 17:42:17 -07:00
|
|
|
card. The Android Dev Phones also feature an unlocked bootloader so you can install custom system
|
2011-01-07 13:46:42 -08:00
|
|
|
images (great for developing and installing custom versions of the Android platform). To find a
|
|
|
|
a place you can purchase the Nexus S, visit <a
|
|
|
|
href="http://www.google.com/phone/detail/nexus-s">google.com/phone</a>. To purchase an Android
|
2010-04-05 17:42:17 -07:00
|
|
|
Dev Phone, see the <a href="http://market.android.com/publish">Android Market</a> site
|
|
|
|
(requires a developer account).</p>
|
|
|
|
|
|
|
|
<p class="note"><strong>Note:</strong> When developing on a device, keep in mind that you should
|
|
|
|
still use the <a
|
2011-08-26 11:50:36 -07:00
|
|
|
href="{@docRoot}guide/developing/devices/emulator.html">Android emulator</a> to test your
|
|
|
|
application
|
2010-04-05 17:42:17 -07:00
|
|
|
on configurations that are not equivalent to those of your real device. Although the emulator
|
|
|
|
does not allow you to test every device feature (such as the accelerometer), it does
|
|
|
|
allow you to verify that your application functions properly on different versions of the Android
|
|
|
|
platform, in different screen sizes and orientations, and more.</p>
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2009-08-26 11:56:57 -07:00
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
<h2 id="setting-up">Setting up a Device for Development</h2>
|
|
|
|
|
2009-08-26 11:56:57 -07:00
|
|
|
<p>With an Android-powered device, you can develop and debug your Android applications just as you
|
2010-04-05 17:42:17 -07:00
|
|
|
would on the emulator. Before you can start, there are just a few things to do:</p>
|
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
<ol>
|
|
|
|
<li>Declare your application as "debuggable" in your Android Manifest.
|
|
|
|
<p>In Eclipse, you can do this from the <b>Application</b> tab when viewing the Manifest
|
2011-08-26 11:50:36 -07:00
|
|
|
(on the right side, set <b>Debuggable</b> to <em>true</em>). Otherwise, in the
|
|
|
|
<code>AndroidManifest.xml</code>
|
|
|
|
file, add <code>android:debuggable="true"</code> to the <code><application></code>
|
|
|
|
element.</p>
|
|
|
|
</li>
|
|
|
|
<li>Set up your device to allow installation of non-Market applications. <p>On
|
|
|
|
the device, go to <strong>Settings > Applications</strong> and enable
|
|
|
|
|
|
|
|
<strong>Unknown sources</strong>.</p>
|
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
</li>
|
|
|
|
<li>Turn on "USB Debugging" on your device.
|
2011-08-26 11:50:36 -07:00
|
|
|
<p>On the device, go to <strong>Settings > Applications > Development</strong>
|
|
|
|
and enable <strong>USB debugging</strong>.</p>
|
2009-03-03 19:31:44 -08:00
|
|
|
</li>
|
2011-08-26 11:50:36 -07:00
|
|
|
<li>Set up your system to detect your device.
|
2009-03-03 19:31:44 -08:00
|
|
|
<ul>
|
2009-11-05 18:53:59 -08:00
|
|
|
<li>If you're developing on Windows, you need to install a USB driver
|
2011-01-07 10:45:03 -08:00
|
|
|
for adb. If you're using an Android Developer Phone (ADP), Nexus One, or Nexus S,
|
|
|
|
see the <a href="{@docRoot}sdk/win-usb.html">Google Windows USB
|
|
|
|
Driver</a>. Otherwise, you can find a link to the appropriate OEM driver in the
|
|
|
|
<a href="{@docRoot}sdk/oem-usb.html">OEM USB Drivers</a> document.</li>
|
2009-03-03 19:31:44 -08:00
|
|
|
<li>If you're developing on Mac OS X, it just works. Skip this step.</li>
|
2011-08-26 11:50:36 -07:00
|
|
|
|
|
|
|
<li>If you're developing on Ubuntu Linux, you need to add a <a
|
|
|
|
href="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html">
|
|
|
|
<code>udev</code></a>
|
|
|
|
rules file that contains a USB configuration for each type of device
|
|
|
|
you want to use for development. In the rules file, each device manufacturer
|
|
|
|
is identified by a unique vendor ID, as specified by the
|
|
|
|
<code>ATTR{idVendor}</code> property. For a list of vendor IDs, see <a
|
|
|
|
href="#VendorIds">USB Vendor IDs</a>, below. To set up device detection on
|
|
|
|
Ubuntu Linux:
|
|
|
|
|
|
|
|
<ol type="a">
|
2009-11-05 18:53:59 -08:00
|
|
|
<li>Log in as root and create this file:
|
2011-08-26 11:50:36 -07:00
|
|
|
<code>/etc/udev/rules.d/51-android.rules</code></span>.
|
|
|
|
<p>Use this format to add each vendor to the file:<br/>
|
|
|
|
<code>SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4",
|
|
|
|
MODE="0666", GROUP="plugdev"</code>
|
|
|
|
<br /><br />
|
|
|
|
|
|
|
|
In this example, the vendor ID is for HTC. The <code>MODE</code>
|
|
|
|
assignment specifies read/write permissions, and <code>GROUP</code> defines
|
|
|
|
which Unix group owns the device node. </p>
|
|
|
|
|
|
|
|
<p class="note"><strong>Note:</strong> The rule syntax
|
|
|
|
may vary slightly depending on your environment. Consult the <code>udev</code>
|
|
|
|
documentation for your system as needed. For an overview of rule syntax, see
|
|
|
|
this guide to <a
|
|
|
|
href="http://www.reactivated.net/writing_udev_rules.html">writing udev
|
|
|
|
rules</a>.</p>
|
2009-03-03 19:31:44 -08:00
|
|
|
</li>
|
|
|
|
<li>Now execute:<br/>
|
2011-08-26 11:50:36 -07:00
|
|
|
<code>chmod a+r /etc/udev/rules.d/51-android.rules</code>
|
2009-03-03 19:31:44 -08:00
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
</ol>
|
2010-04-05 17:42:17 -07:00
|
|
|
|
2011-08-26 11:50:36 -07:00
|
|
|
<p>You can verify that your device is connected by executing <code>adb
|
|
|
|
devices</code> from your SDK {@code platform-tools/} directory. If connected,
|
|
|
|
you'll see the device name listed as a "device."</p>
|
2010-04-05 17:42:17 -07:00
|
|
|
|
2011-08-26 11:50:36 -07:00
|
|
|
<p>If using Eclipse, run or debug your application as usual. You will be
|
|
|
|
presented with a <b>Device Chooser</b> dialog that lists the available
|
|
|
|
emulator(s) and connected device(s). Select the device upon which you want to
|
|
|
|
install and run the application.</p>
|
2009-11-05 18:53:59 -08:00
|
|
|
|
2011-08-26 11:50:36 -07:00
|
|
|
<p>If using the <a href="{@docRoot}guide/developing/tools/adb.html">Android
|
|
|
|
Debug Bridge</a> (adb), you can issue commands with the <code>-d</code> flag to
|
|
|
|
target your connected device.</p>
|
2009-11-05 18:53:59 -08:00
|
|
|
|
|
|
|
<h3 id="VendorIds">USB Vendor IDs</h3>
|
2011-08-26 11:50:36 -07:00
|
|
|
|
|
|
|
<p>This table provides a reference to the vendor IDs needed in order to add USB
|
|
|
|
device support on Linux. The USB Vendor ID is the value given to the
|
|
|
|
<code>ATTR{idVendor}</code> property in the rules file, as described
|
|
|
|
above.</p>
|
2010-04-05 17:42:17 -07:00
|
|
|
|
2009-11-05 18:53:59 -08:00
|
|
|
<table>
|
|
|
|
<tr>
|
2011-03-08 16:32:09 -08:00
|
|
|
<th>Company</th><th>USB Vendor ID</th></tr>
|
2009-11-05 18:53:59 -08:00
|
|
|
<tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<td>Acer</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>0502</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>ASUS</td>
|
|
|
|
<td><code>0b05</code></td>
|
|
|
|
</tr>
|
2009-11-05 18:53:59 -08:00
|
|
|
<tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<td>Dell</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>413c</code></td>
|
|
|
|
</tr>
|
2009-11-05 18:53:59 -08:00
|
|
|
<tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<td>Foxconn</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>0489</code></td>
|
|
|
|
</tr>
|
2009-11-05 18:53:59 -08:00
|
|
|
<tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<td>Garmin-Asus</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>091E</code></td>
|
|
|
|
</tr>
|
2011-03-08 16:32:09 -08:00
|
|
|
<tr>
|
|
|
|
<td>Google</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>18d1</code></td>
|
|
|
|
</tr>
|
2009-11-05 18:53:59 -08:00
|
|
|
<tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<td>HTC</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>0bb4</code></td>
|
|
|
|
</tr>
|
2009-11-05 18:53:59 -08:00
|
|
|
<tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<td>Huawei</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>12d1</code></td>
|
|
|
|
</tr>
|
2011-07-13 09:36:56 -07:00
|
|
|
<tr>
|
|
|
|
<td>K-Touch</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>24e3</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>KT Tech</td>
|
|
|
|
<td><code>2116</code></td>
|
|
|
|
</tr>
|
2009-11-05 18:53:59 -08:00
|
|
|
<tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<td>Kyocera</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>0482</code></td>
|
|
|
|
</tr>
|
2011-06-20 15:50:12 -07:00
|
|
|
<tr>
|
|
|
|
<td>Lenevo</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>17EF</code></td>
|
|
|
|
</tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<tr>
|
|
|
|
<td>LG</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>1004</code></td>
|
|
|
|
</tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<tr>
|
|
|
|
<td>Motorola</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>22b8</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>NEC</td>
|
|
|
|
<td><code>0409</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Nook</td>
|
|
|
|
<td><code>2080</code></td>
|
|
|
|
</tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<tr>
|
|
|
|
<td>Nvidia</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>0955</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>OTGV</td>
|
|
|
|
<td><code>2257</code></td>
|
|
|
|
</tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<tr>
|
|
|
|
<td>Pantech</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>10A9</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Pegatron</td>
|
|
|
|
<td><code>0x1D4D</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Philips</td>
|
|
|
|
<td><code>0471</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>PMC-Sierra</td>
|
|
|
|
<td><code>04da</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Qualcomm</td>
|
|
|
|
<td><code>05c6</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>SK Telesys</td>
|
|
|
|
<td><code>1f53</code></td>
|
|
|
|
</tr>
|
2011-08-24 19:27:25 -07:00
|
|
|
<tr>
|
|
|
|
<td>Pegatron</td>
|
|
|
|
<td><code>0x1D4D</code></td></tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<tr>
|
|
|
|
<td>Samsung</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>04e8</code></td>
|
|
|
|
</tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<tr>
|
|
|
|
<td>Sharp</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>04dd</code></td>
|
|
|
|
</tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<tr>
|
|
|
|
<td>Sony Ericsson</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>0fce</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Toshiba</td>
|
|
|
|
<td><code>0930</code></td>
|
|
|
|
</tr>
|
2010-04-05 17:42:17 -07:00
|
|
|
<tr>
|
|
|
|
<td>ZTE</td>
|
2011-08-26 11:50:36 -07:00
|
|
|
<td><code>19D2</code></td>
|
|
|
|
</tr>
|
2009-11-05 18:53:59 -08:00
|
|
|
</table>
|