概念
adb是一个和安卓设备交互的工具
组成
- A
client
, which sends commands. The client runs on yourdevelopment machine
. You can invoke a client from a command-line terminal by issuing anadb
command. - A
daemon
(adbd), which runs commands on adevice
. The daemon runs as a background process on each device. - A
server
, which manages communication between the client and the daemon. The server runs as a background process on yourdevelopment machine
.
术语说明:
development machine: 开发安卓项目的机器
device: 安卓实机或者安卓模拟器
server: 默认运行端口5037
ADB命令
# 查看设备
adb devices -l
# 启动或杀死server
adb kill-server
adb start-server
# 安装应用
adb install helloWorld.apk
# 指定设备
adb -s emulator-5555 install helloWorld.apk # serial number
adb -e install helloWorld.apk # emulator
adb -d install helloWorld.apk # hardware device
# 端口转发,将PC端的6100端口收到的数据,转发给到手机中7100端口
adb forward tcp:6100 tcp:7100
# 拷贝文件
adb pull remote local
adb push local remote
# WiFi-Debug
adb pair HOST[:PORT] [PAIRING CODE]
adb connect HOST[:PORT]
ABD shell命令
adb [-d |-e | -s serial_number] shell shell_command
adb shell