如何在真实设备上调试(使用Eclipse/ADT)

发布于 2024-08-31 00:45:04 字数 144 浏览 5 评论 0原文

我正在尝试弄清楚如何直接在我的手机(HTC Desire)上调试应用程序。

我已经安装了手机附带的 USB 驱动程序,并且使用“adb devices”时会列出手机。

如何配置 eclipse/ADT 在手机上启动而不是启动模拟器/虚拟设备?

I'm trying to figure out how to debug applications directly on my phone (HTC Desire).

I've installed the USB driver that came with the phone and the phone is listed when using "adb devices".

How do I configure eclipse/ADT to launch on the phone instead of launching the emulator/virtual device?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浮生未歇 2024-09-07 00:45:04

注意:此答案是 本指南曾经存在于developer.android.com。其中部分内容是从原文中逐字引用的,没有注明所引用的特定部分的出处。


使用 Android 设备,您可以像在模拟器上一样开发和调试 Android 应用程序。

1.在 AndroidManifest.xml 中将您的应用程序声明为“可调试”。

<application
    android:debuggable="true"
    ... >
    ...
</application>

2.在手机上,导航至“设置”>“安全性和检查未知来源

在此处输入图像描述

3.转到设置>开发者选项并选中USB调试
请注意,如果开发者选项不可见,您将需要导航到“设置”>“开发者选项”。关于手机,然后多次点击版本号,直到您收到手机已解锁的通知。

在此处输入图像描述

4.设置您的系统以检测您的设备。
请按照以下适用于您的操作系统的说明进行操作:


Windows 用户

从 ADT SDK 管理器安装 Google USB 驱动程序
(支持:ADP1、ADP2、Verizon Droid、Nexus One、Nexus S)。

在此处输入图像描述

对于上面未列出的设备,为您的设备安装 OEM 驱动程序


Mac OS X

您的设备应该自动工作;转到下一步


Ubuntu Linux

添加一个 udev 规则文件,其中包含要用于开发的每种类型设备的 USB 配置。在规则文件中,每个设备制造商都由唯一的供应商 ID 进行标识,如 ATTR{idVendor} 属性所指定。如需供应商 ID 列表,单击此处。要在 Ubuntu Linux 上设置设备检测:

  1. 以 root 身份登录并创建此文件:/etc/udev/rules.d/51-android.rules
  2. 使用此格式将每个供应商添加到文件中:
    SUBSYSTEM==“usb”,ATTR{idVendor}==“0bb4”,MODE =“0666”,GROUP =“plugdev”
    在此示例中,供应商 ID 是 HTC 的。 MODE 指定指定读/写权限,GROUP 定义哪个 Unix 组拥有设备节点。
  3. 现在执行:chmod a+r /etc/udev/rules.d/51-android.rules code>

注意:规则语法可能会因您的环境而略有不同。请参阅udev 文档 适合您的系统需要。有关规则语法的概述,请参阅本 udev 规则编写指南


5.使用连接的设备运行项目。

使用 Eclipse/ADT: 像往常一样运行或调试您的应用程序。您将看到一个设备选择器对话框,其中列出了可用的模拟器和连接的设备。

使用 ADB: 发出带有 -d 标志的命令来定位目标您连接的设备。

Note: This answer is a heavily modified version of this guide that used to exist at developer.android.com. Portions of it are quoted verbatim from the original text without attribution for the specific parts that are quoted.


With an Android-powered device, you can develop and debug your Android applications just as you would on the emulator.

1. Declare your application as "debuggable" in AndroidManifest.xml.

<application
    android:debuggable="true"
    ... >
    ...
</application>

2. On your handset, navigate to Settings > Security and check Unknown sources

enter image description here

3. Go to Settings > Developer Options and check USB debugging
Note that if Developer Options is invisible you will need to navigate to Settings > About Phone and tap on Build number several times until you are notified that it has been unlocked.

enter image description here

4. Set up your system to detect your device.
Follow the instructions below for your OS:


Windows Users

Install the Google USB Driver from the ADT SDK Manager
(Support for: ADP1, ADP2, Verizon Droid, Nexus One, Nexus S).

enter image description here

For devices not listed above, install an OEM driver for your device


Mac OS X

Your device should automatically work; Go to the next 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, click here. To set up device detection on Ubuntu Linux:

  1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules.
  2. 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.
  3. Now execute: chmod a+r /etc/udev/rules.d/51-android.rules

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.


5. Run the project with your connected device.

With Eclipse/ADT: 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).

With ADB: issue commands with the -d flag to target your connected device.

冰雪之触 2024-09-07 00:45:04

有时您需要重置 ADB。
为此,在 Eclipse 中,转到:

Window>>
显示视图>>
安卓
(可能在“其他”选项中找到)>>

设备选项卡中的设备,单击向下箭头,然后选择重置 adb。

Sometimes you need to reset ADB.
To do that, in Eclipse, go:

Window>>
Show View >>
Android
(Might be found in the "Other" option)>>Devices

in the device Tab, click the down arrow, and choose reset adb.

在你怀里撒娇 2024-09-07 00:45:04

在具有 Android 4.3 及更高版本的设备中,您应该按照以下步骤操作:

如何启用开发人员选项:

Launch Settings menu.
Find the open the ‘About Device’ menu.
Scroll down to ‘Build Number’.
Next, tap on the ‘build number’ section seven times.
After the seventh tap you will be told that you are now a developer.
Go back to Settings menu and the Developer Options menu will now be displayed.

为了启用 USB 调试,您只需打开开发人员选项,向下滚动并勾选“USB 调试”框。就是这样。

in devices which has Android 4.3 and above you should follow these steps:

How to enable Developer Options:

Launch Settings menu.
Find the open the ‘About Device’ menu.
Scroll down to ‘Build Number’.
Next, tap on the ‘build number’ section seven times.
After the seventh tap you will be told that you are now a developer.
Go back to Settings menu and the Developer Options menu will now be displayed.

In order to enable the USB Debugging you will simply need to open Developer Options, scroll down and tick the box that says ‘USB Debugging’. That’s it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文