ADB Android 调试器 下载器

来源:互联网 发布:江苏悠迅网络正规吗 编辑:程序博客网 时间:2024/06/05 09:18


   adb是一个万能的工具,让你可以管理android设备的状态,更多关于adb的信息可以参考:http://developer.android. com/guide/developing/tools/adb.html.

ADB大概有以下用途:

  1. 在主机上下载安装apk应用程序,在目标设备上启动运行;
  2. 在主机上启动目标设备的shell;
  3. 使用DDMS(Dalvik Debug Monitor Server,运行在ADB的上层)工具调试运行在设备的应用程序;
  4. 主机和设备之间拷贝文件;

下载“ADB”和安装配置主机(Ubuntu-12.04)

  adb是android SDK包的一部分,在这个地方可以找到:http://developer.android.com/sdk/index.html,按照连接里的步骤安装完Android SDK后,接着执行下面命令配置环境变量:

$ export PATH=<android_sdk_path>/platform-tools/:<android_sdk_path>/tools/:$PATH

通过adb连接主机和设备,有以下三种方式:

  1. 通过USB
  2. 通过网络

通过USB

  首先确保主机与设备的usb连接,然后设备里的开发者选项,开启usb调试

以管理员权限创建/etc/udev/rules.d/51-android.rules文件,让主机能够检测到设备,在文件中添加设备ID,如:18d1,如果是usb设备可以用lsusb命令看到当前连接主机usb设备的ID

SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"

保存退出。

执行下面命令:

$ chmod a+r /etc/udev/rules.d/51-android.rules

注:建议改变上面配置后重启主机系统。

最后adb devices察看是否有连接的设备,如果连接上了,例如:

List of devices attached
20100720
device

通过网络-以太网

确保主机和设备以太网已经开启;

查看设备网络设置:

# netcfg
lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00
sit0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00
eth0 UP 192.168.0.100/22 0x00001043 96:cd:df:8b:c6:2b

通过setprop配置设备机器的adb Daemon:

# setprop service.adb.tcp.port 5555

如果通过上面的步骤,网络配置成功,可以执行一下命令重启目标板的adb服务:

# stop adbd
# start adbd

在主机端执行下面命令建立adb连接:

$ export ADBHOST=<target's ip address>
$ adb kill-server
$ adb start-server
$ adb connect <target_ip_address>:5555

执行以下命令查看是否连上:

$ adb devices

如果连接上了,就会有设备列表:

List of devices attached
172.24.191.26:5555    device

启动目标板的shell

$ adb shell

 

adb Windows PC下通过USB 连接

大体步骤如下:

  1. 下载最新Android SDK
  2. 配置环境变量
  3. 下载Android USB 驱动(https://dl-ssl.google.com/android/repository/usb_driver_r03-windows.zip) 解压到(i.e. c:\android_sdk\usb_driver)
  4. 修改(或创建文件)"%USERPROFILE%\.android\adb_usb.ini":
    > echo 0x18D1 > "%USERPROFILE%\.android\adb_usb.ini"
  5. 修改 android_winusb.inf 文件配置EVM/Beagle vendor and product ids:
    在[Google.NTx86]段下添加:
    ;TI EVM
    %SingleAdbInterface%  = USB_Install, USB\VID_18D1&PID_9018
    %CompositeAdbInterface%  = USB_Install, USB\VID_18D1&PID_9018&MI_01

     如果是amd64位,就在Google.NTamd64段下加。

  6. 连接usb启动设备;

  7. 如果正常的话Windows会提示安装设备驱动;

Answer "No, not this time" to the question about running Windows Update to search for software.
• Choose "Install the hardware that I manually select from a list (Advanced)" this is the 2nd option, then click
"Next"
• Select "Show All Devices", then click "Next"
• You are going to see a grayed-out text box with "(Retrieving a list of all devices)", click the "Have Disk..."
button
• Browse" to your driver folder (c:\android_sdk\usb_driver). It will be looking of a .inf file so select
"android_winusb.inf" and click "Open" then "OK". It's the only file there so you shouldn't go wrong.
• Select "Android ADB Interface" then click the "Next" button.
• A warning will appear, answer "Yes" but read the warning anyway.
• Click the "Close" when the wizard is completed.

8. 正常设置完毕后,

> adb kill-server
> adb start-server

下来就可以使用命令了。

基本操作设备名令:

1. 安装apk

$ adb install <package>.apk

要安装到外部设备的话加-s

2. 卸载apk

方法一:

adb shell pm list packages

adb uninstall <package name>

方法二:

进入设置-应用程序下卸载

卸载系统自带默认的程序:

$adb shell

# rm /system/app/app.apk

3.主机和设备之间拷贝文件

adb push <local> <remote>

adb pull <remote> <local>

 

参考:TI Devkit userguide 文档

原创粉丝点击