Ubuntu下android真机调试Using Hardware Devices

官网地址:http://developer.android.com/guide/developing/device.html#setting-up


Using Hardware Devices

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.

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.

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, visitgoogle.com/phone. To purchase an Android Dev Phone, see theAndroid Marketsite (requires a developer account).

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

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. Declare your application as "debuggable" in your Android Manifest.

    In Eclipse, you can do this from theApplicationtab when viewing the Manifest (on the right side, setDebuggabletotrue). Otherwise, in theAndroidManifest.xmlfile, addandroid:debuggable="true"to the<application>element.

  2. Set up your device to allow installation of non-Market applications.

    On the device, go toSettings > Applicationsand enableUnknown sources.

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

    On the device, go toSettings > Applications > Developmentand enableUSB debugging.

  4. Set up your system to detect your device.
    • 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 theGoogle Windows USB Driver. Otherwise, you can find a link to the appropriate OEM driver in theOEM USB Driversdocument.
    • 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 audevrules 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 theATTR{idVendor}property. For a list of vendor IDs, seeUSB 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. TheMODEassignment specifies read/write permissions, andGROUPdefines which Unix group owns the device node.

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

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

You can verify that your device is connected by executingadb devicesfrom your SDKplatform-tools/directory. If connected, you'll see the device name listed as a "device."

If using Eclipse, run or debug your application as usual. You will be presented with aDevice Chooserdialog 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 theAndroid Debug Bridge(adb), you can issue commands with the-dflag 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.

Company USB Vendor ID
Acer 0502
ASUS 0b05
Dell 413c
Foxconn 0489
Garmin-Asus 091E
Google 18d1
HTC 0bb4
Huawei 12d1
K-Touch 24e3
KT Tech 2116
Kyocera 0482
Lenevo 17EF
LG 1004
Motorola 22b8
NEC 0409
Nook 2080
Nvidia 0955
OTGV 2257
Pantech 10A9
Philips 0471
PMC-Sierra 04da
Qualcomm 05c6
SK Telesys 1f53
Samsung 04e8
Sharp 04dd
Sony Ericsson 0fce
Toshiba 0930
ZTE 19D2

### Ubuntu Firmware Repository and Resources Ubuntu provides comprehensive support for firmware through its repositories and additional resources dedicated to hardware enablement. The primary sources include: #### Official Repositories The official Ubuntu package repository contains a wide range of firmware packages that are essential for various hardware components. These can be found within the `non-free` section of the archive, which includes proprietary drivers and firmware necessary for certain devices. For example, users may install these using standard APT commands: ```bash sudo apt update && sudo apt install linux-firmware ``` This command installs the main collection of non-free firmware for Linux kernels[^1]. #### Additional Resources Beyond the core distribution, Canonical maintains several projects aimed at improving hardware compatibility with Ubuntu systems. One notable project is the **Linux Hardware Database**, where community members contribute information about their hardware configurations along with any required firmware updates or patches. Another valuable resource is the **Ubuntu Kernel Team Wiki Pages**. This site offers detailed guides on how to manage and develop firmware specifically tailored for use with Ubuntu distributions. It covers topics such as building custom kernel images, integrating new device drivers into existing setups, and troubleshooting common issues related to specific pieces of hardware. Furthermore, developers interested in contributing directly towards enhancing firmware capabilities might consider joining relevant mailing lists hosted by Canonical or participating actively in forums like AskUbuntu.com, where discussions often revolve around advanced configuration options available under different versions of this popular Linux distro. Finally, it's worth noting that some specialized tools exist outside traditional channels but still play crucial roles when working closely with low-level system operations involving firmwares; one prominent toolset being mentioned here would be UEFI Secure Boot utilities provided alongside GRUB bootloader installations during typical desktop/server deployments.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值