Skip to content

Most visited

Recently visited

navigation

Run Apps on a Hardware Device

When building an Android app, it's important that you always test your app on a real device before releasing it to users. This page describes how to set up your development environment and Android device for testing and debugging.

Set up a device for development

Before you can start debugging on your device, there are a few things you must do:

  1. In the build.gradle file, set the debuggable property of the debug build type to true:
    android {
        buildTypes {
            debug {
                debuggable true
            }
     }
    
  2. On the device, open the Settings app, select Developer options, and then enable USB debugging.
  3. Set up your system to detect your device.
    • Windows: Install a USB driver for Android Debug Bridge (adb). For an installation guide and links to OEM drivers, see the Install OEM USB Drivers document.
    • Mac OS X: It just works. Skip this step.
    • Ubuntu Linux: Add a udev 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 ATTR{idVendor} property. For a list of vendor IDs, see USB vendor IDs.

      To set up device detection on Ubuntu Linux, do the following:

      1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules.
      2. Use the following format to add each vendor to the file:

        SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"

        In this example, the vendor ID is for HTC. The MODE assignment specifies read/write permissions, and GROUP defines which Unix group owns the device node.

      3. Run the following command:
        chmod a+r /etc/udev/rules.d/51-android.rules

Connect to your device

When you are set up and plugged in over USB, you can click Run in Android Studio to build and run your app on the device.

You can also use adb to issue commands, as follows:

RSA security key

When you connect a device running Android 4.2.2 (API level 17) or higher to your computer, the system shows a dialog asking whether to accept an RSA key that allows debugging through this computer. This security mechanism protects user devices because it ensures that USB debugging and other adb commands cannot be executed unless you're able to unlock the device and acknowledge the dialog.

USB vendor IDs

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 ATTR{idVendor} property in the rules file, as described above.

CompanyUSB vendor ID
Acer 0502
ASUS 0b05
Dell 413c
Foxconn 0489
Fujitsu 04c5
Fujitsu Toshiba 04c5
Garmin-Asus 091e
Google 18d1
Haier 201E
Hisense 109b
HP 03f0
HTC 0bb4
Huawei 12d1
Intel 8087
K-Touch 24e3
KT Tech 2116
Kyocera 0482
Lenovo 17ef
LG 1004
Motorola 22b8
MTK 0e8d
NEC 0409
Nook 2080
Nvidia 0955
OTGV 2257
Pantech 10a9
Pegatron 1d4d
Philips 0471
PMC-Sierra 04da
Qualcomm 05c6
SK Telesys 1f53
Samsung 04e8
Sharp 04dd
Sony 054c
Sony Ericsson 0fce
Sony Mobile Communications 0fce
Teleepoch 2340
Toshiba 0930
ZTE 19d2
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.