Android SDK中的必会工具——ADB是真的香

前面的内容请参见Android应用自动化测试-提纲。 这篇我们将介绍在Android SDK中一个非常关键的工具,ADB。可以说ADB是Android开发、自动化测试的基础。


ADB即Android Debug Bridge,android调试桥,是开发设备(PC)和android设备之间的连接通道,通过它,开发者可以在PC端实现对设备的连接、控制和一些基本操作。

ADB的组成如图

img

在PC端:
ADB由Client和Server两部分组成,client即我们运行ADB的命令行程序,用于接收我们的操作指定,并和server端通过5037端口进行通信,server端启动后和5037端口绑定,与client端交互并建立和设备端的adbd通信,一般设备端是5555端口,PC端则使用5554端口。多个不同设备会成对分配(5556:5557…)
在Device端:
则运行了adbd,即adb在设备上的守护进程,随时接收来自PC端的指令。模拟器是默认开启的,真机在我们开启了开发者的调试模式以后,也就是启动了adbd进程。

ADB工具的作用非常多,在命令行中运行adb help可以得到以下输出,列出了adb支持的使用命令清单。

c:>adb help
Android Debug Bridge version 1.0.36
Revision 0e9850346394-android

-a                            - directs adb to listen on all interfaces for a connection
-d                            - directs command to the only connected USB device
                                returns an error if more than one USB device is present.
-e                            - directs command to the only running emulator.
                                returns an error if more than one emulator is running.
-s <specific device>          - directs command to the device or emulator with the given
                                serial number or qualifier. Overrides ANDROID_SERIAL environment variable.
-p <product name or path>     - simple product name like 'sooner', or a relative/absolute path to a product 
                                out directory like 'out/target/product/sooner'.If -p is not specified, the 
                                ANDROID_PRODUCT_OUT environment variable is used, which mustbe an absolute path.
-H                              - Name of adb server host (default: localhost)
-P                              - Port of adb server (default: 5037)
devices [-l]                   - list all connected devices
                             ('-l' will also list device qualifiers)
connect <host>[:<port>]       - connect to a device via TCP/IP
                             Port 5555 is used by default if no port number is specified.
 disconnect [<host>[:<port>]]  - disconnect from a TCP/IP device.
                             Port 5555 is used by default if no port number is specified.
                             Using this command with no additional arguments
                             will disconnect from all connected TCP/IP devices.

device commands:

a
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值