본문 바로가기
User Guide

하드웨어장치에서 App 실행시키기 Run Apps on a Hardware Device (24)

by 각종 잡상식 지식 모음 2016. 6. 10.
반응형

하드웨어장치에서 App 실행시키기
Run Apps on a Hardware Device

When building an Android app, 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.

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 Android Studio 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.

If you want a SIM-unlocked phone, then you might consider a Nexus phone. To purchase a Nexus phone, visit the Google Play store.

Note: When developing on a device, keep in mind that you should still use the Android emulator 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.

Enabling On-device Developer Options


Android-powered devices have a host of developer options that you can access on the phone, which let you:

  • Enable debugging over USB.
  • Quickly capture bug reports onto the device.
  • Show CPU usage on screen.
  • Draw debugging information on screen such as layout bounds, updates on GPU views and hardware layers, and other information.
  • Plus many more options to simulate app stresses or enable debugging options.

To access these settings, open the Developer options in the system Settings. On Android 4.2 and higher, the Developer options screen is hidden by default. To make it visible, go toSettings > About phone and tap Build number seven times. Return to the previous screen to find Developer options at the bottom.

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. Before you can start, there are just a few things to do:

  1. Verify that your application is "debuggable" in your manifest or build.gradle file.

    In the build file, make sure the debuggable property in the debug build type is set to true. The build type property overrides the manifest setting.

    android {
        buildTypes
    {
            debug
    {
                debuggable
    true
           
    }

    In the AndroidManifest.xml file, add android:debuggable="true" to the <application> element.

    Note: If you manually enable debugging in the manifest file, be sure to disable it in your release build (your published application should usuallynot be debuggable).

  2. Enable USB debugging on your device by going to Settings > Developer options.

    Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.

  3. Set up your system to detect your device.
    • If you're developing on Windows, you need to install a USB driver for adb. For an installation guide and links to OEM drivers, see the OEM USB Drivers document.
    • 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 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, below. To set up device detection on Ubuntu Linux:
      1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules.

        Use this 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.

        Note: The rule syntax may vary slightly depending on your environment. Consult the udev documentation for your system as needed. For an overview of rule syntax, see this guide to writing udev rules.

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

Note: When you connect a device running Android 4.2.2 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. This requires that you have adb version 1.0.31 (available with SDK Platform-tools r16.0.1 and higher) in order to debug on a device running Android 4.2.2 or higher.

When plugged in over USB, you can verify that your device is connected by executing adb devices from your SDK platform-tools/ directory. If connected, you'll see the device name listed as a "device."

If using Android Studio, run or debug your application as usual. You will be presented with a Device Chooser dialog that lists the available emulator(s) and connected device(s). Select the device upon which you want to install and run the application.

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 USB device support on Linux. The USB Vendor ID is the value given to theATTR{idVendor} property in the rules file, as described above.

CompanyUSB Vendor ID
Acer0502
ASUS0b05
Dell413c
Foxconn0489
Fujitsu04c5
Fujitsu Toshiba04c5
Garmin-Asus091e
Google18d1
Haier201E
Hisense109b
HP03f0
HTC0bb4
Huawei12d1
Intel8087
K-Touch24e3
KT Tech2116
Kyocera0482
Lenovo17ef
LG1004
Motorola22b8
MTK0e8d
NEC0409
Nook2080
Nvidia0955
OTGV2257
Pantech10a9
Pegatron1d4d
Philips0471
PMC-Sierra04da
Qualcomm05c6
SK Telesys1f53
Samsung04e8
Sharp04dd
Sony054c
Sony Ericsson0fce
Sony Mobile Communications0fce
Teleepoch2340
Toshiba0930
ZTE19d2


반응형

댓글