前面的内容请参见Android应用自动化测试-提纲。 这篇我们将介绍在Android SDK中一个非常关键的工具,ADB。可以说ADB是Android开发、自动化测试的基础。
ADB即Android Debug Bridge,android调试桥,是开发设备(PC)和android设备之间的连接通道,通过它,开发者可以在PC端实现对设备的连接、控制和一些基本操作。
ADB的组成如图
在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
Android SDK中的必会工具——ADB是真的香
最新推荐文章于 2024-02-04 09:00:00 发布