summaryrefslogtreecommitdiffstats
path: root/docs/html/guide/developing/device.jd
blob: 3127e10f3f5fb4a9865c65b77fae00f4533164e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
page.title=Using Hardware Devices
@jd:body

<div id="qv-wrapper">
<div id="qv">
  <h2>In this document</h2>
  <ol>
    <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>
    <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>
  </ol>
</div>
</div>

<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
device directly from Eclipse or from the command line with ADB. If
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
Google Nexus S. These are SIM-unlocked so that you can use them on any GSM network using a SIM
card. The Android Dev Phones also feature an unlocked bootloader so you can install custom system
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
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
href="{@docRoot}guide/developing/devices/emulator.html">Android emulator</a> to test your application
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>


<h2 id="setting-up">Setting up a Device for Development</h2>

<p>With an Android-powered device, you can develop and debug your Android applications just as you
would on the emulator. Before you can start, there are just a few things to do:</p>

<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
    (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>&lt;application></code> element.</p>
  </li>
  <li>Turn on "USB Debugging" on your device.
    <p>On the device, go to the home screen, press <b>MENU</b>, select <b>Applications</b> > <b>Development</b>,
    then enable <b>USB debugging</b>.</p>
  </li>
  <li>Setup your system to detect your device.
    <ul>
      <li>If you're developing on Windows, you need to install a USB driver
      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>
      <li>If you're developing on Mac OS X, it just works. Skip this step.</li>
      <li>If you're developing on Ubuntu Linux, you need to add a rules file
that contains a USB configuration for each type of device you want to use for
development. Each device manufacturer uses a different vendor ID. The
example rules files below show how to add an entry for a single vendor ID
(the HTC vendor ID). In order to support more devices, you will need additional
lines of the same format that provide a different value for the
<code>SYSFS{idVendor}</code> property. For other IDs, see the table of <a
href="#VendorIds">USB Vendor IDs</a>, below.
        <ol>
          <li>Log in as root and create this file:
            <code>/etc/udev/rules.d/51-android.rules</code>.
            <p>For Gusty/Hardy, edit the file to read:<br/>
            <code>SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4",
            MODE="0666"</code></p>

            <p>For Dapper, edit the file to read:<br/>
            <code>SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4",
            MODE="0666"</code></p>
          </li>
          <li>Now execute:<br/>
              <code>chmod a+r /etc/udev/rules.d/51-android.rules</code>
          </li>
        </ol>
      </li>
    </ul>
  </li>
</ol>

<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>

<p>If using Eclipse, run or debug 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>

<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>


<h3 id="VendorIds">USB Vendor IDs</h3>
<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>SYSFS{idVendor}</code> property in the rules file, as described in step 3, above.</p>

<table>
  <tr>
    <th>Company</th><th>USB Vendor ID</th></tr>
  <tr>
    <td>Acer</td>
    <td><code>0502</code></td></tr>
  <tr>
    <td>Dell</td>
    <td><code>413c</code></td></tr>
  <tr>
    <td>Foxconn</td>
    <td><code>0489</code></td></tr>
  <tr>
    <td>Garmin-Asus</td>
    <td><code>091E</code></td></tr>
  <tr>
    <td>Google</td>
    <td><code>18d1</code></td></tr>
  <tr>
    <td>HTC</td>
    <td><code>0bb4</code></td></tr>
  <tr>
    <td>Huawei</td>
    <td><code>12d1</code></td></tr>
  <tr>
    <td>Kyocera</td>
    <td><code>0482</code></td></tr>
  <tr>
    <td>LG</td>
    <td><code>1004</code></td></tr>
  <tr>
    <td>Motorola</td>
    <td><code>22b8</code></td></tr>
  <tr>
    <td>Nvidia</td>
    <td><code>0955</code></td></tr>
  <tr>
    <td>Pantech</td>
    <td><code>10A9</code></td></tr>
  <tr>
    <td>Samsung</td>
    <td><code>04e8</code></td></tr>
  <tr>
    <td>Sharp</td>
    <td><code>04dd</code></td></tr>
  <tr>
    <td>Sony Ericsson</td>
    <td><code>0fce</code></td></tr>
  <tr>
    <td>ZTE</td>
    <td><code>19D2</code></td></tr>
</table>