Developing on a Device

When building mobile applications, it's vital to test them on real devices prior to releasing them to users. This page covers what you need to know, including the types of devices that you can use, and how to set one up for developing and debugging.

Available Devices

Here are some options for obtaining devices capable of testing your applications.

Consumer devices

It's likely that one of your local mobile carriers offers an Android-powered device. Any Android-powered device (even one bought from your mobile carrier) is a perfectly good device for running and testing your own Android applications. You can write applications using the Android SDK and then install them directly onto the device for testing.

Check with the service providers in your area to determine which Android-powered devices are available.

Be aware that consumer devices are not designed to allow system image updates by the user. If you're interested in manually updating the device with custom system images, then you'll need a developer device such as the Android Dev Phone 1.

Android Dev Phone 1

The Android Dev Phone 1 is a SIM-unlocked and hardware-unlocked device that is designed for advanced developers. The device ships with a system image that is fully compatible with Android 1.0, so you can rely on it when developing your applications. You can use any SIM in the device and can flash custom Android builds that will work with the unlocked bootloader. Unlike the bootloader on retail devices, the bootloader on the Android Dev Phone 1 does not enforce signed system images. The Android Dev Phone 1 should also appeal to developers who live in geographies where local mobile carriers do not currently offer Android-powered devices.

To purchase an Android Dev Phone 1 device, you must first register as an Android developer on the Android Market site, if you haven't done so already. Once you've logged into your developer account on Android Market, you can purchase the device by following the link to "Development phones." To accommodate demand, there is a limit of 1 device per developer account, for now.

The device currently costs $399 (USD) (including free shipping in the US), and is available for purchase in 18 international markets, including the US, UK, Germany, Japan, India, Canada, France, Taiwan, Spain, Australia, Singapore, Switzerland, Netherlands, Austria, Sweden, Finland, Poland, and Hungary. We will continue to expand this program into new geographies over time. Check this page for updated information.

Android Dev Phone 1 devices are not intended for non-developer end-users. Because the device can be configured with system software not provided by or supported by Google or any other company, end-users operate these devices at their own risk.

Note that your Android Dev Phone 1 will not receive automated over-the-air (OTA) updates for the system image. System updates must be flashed manually. See the HTC site for a guide to Flashing your Android Dev Phone with a Factory System Image.

For full device specs and more information about obtaining an Android Dev Phone 1 device, see the Android Market site.

Setting up a Device for Development

With an Android-powered device, you can develop and debug your Android applications just as you would on the emulator. There are just a few things to do before you can start.

  1. Declare your application as "debuggable" in your Android Manifest.

    In Eclipse, you can do this from the Application tab when viewing the Manifest (on the right side, set Debuggable to true). Otherwise, in the AndroidManifest.xml file, add android:debuggable="true" to the <application> element.

  2. Turn on "USB Debugging" on your device.

    On the device, go to the home screen, press MENU, select Applications > Development, then enable USB debugging.

  3. Setup your system to detect your device.
    • If you're developing on Windows, you need to install a USB driver for adb. See the Windows USB Driver documentation.
    • If you're developing on Mac OS X, it just works. Skip this step.
    • 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 SYSFS{idVendor} property. For other IDs, see the table of USB Vendor IDs, below.
      1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules.

        For Gusty/Hardy, edit the file to read:
        SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

        For Dapper, edit the file to read:
        SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0666"

      2. Now execute:
        chmod a+r /etc/udev/rules.d/51-android.rules

You can verify that your device is connected by executing adb devices from your SDK tools/ directory. If connected, you'll see the device name listed as a "device."

If using Eclipse, select run or debug as usual. You will be presented with a Device Chooser dialog that lists the available emulator(s) and connected device(s). Select the device to install and run the application there.

If using the Android Debug Bridge (adb), you can issue commands with the -d flag to target your connected device.

USB Vendor IDs

This table provides a reference to the vendor IDs needed in order to add device support on Linux. The USB Vendor ID is the value given to the SYSFS{idVendor} property in the rules file.

ManufacturerUSB Vendor ID
Acer0502
HTC0bb4
Huawei12d1
LG1004
Motorola22b8
Samsung04e8
Sony Ericsson0fce
↑ Go to top