ADB经常使用命令

查看设备

adb devices

开启/关闭adb服务

adb start-server 
adb kill-server

链接/断开设备(这个会在三星在线机型测试使用到/wifi调试时使用到–>三星远程开发测试平台

// 使用在线调试
adb tcpip 5555 // 设置调试端口号
adb connect ip  // 连接ip设备
adb disconnect ip   // 取消连接ip设备

// 使用usb调试
adb usb // 使用usb调试
ip为能够访问到的设备ip

安装apk

adb install -t ***.apk

查看已安装的应用

adb shell pm list packages  // 查看全部应用
adb shell pm list packages -s   // 查看系统应用
adb shell pm list packages -3   // 查看三方应用

启动应用

adb shell am start -n 包名/相对包名的类名
如:adb shell am start -n com.example.test/.MainActivity

文件传输

pull:获取文件
adb pull 要获取的文件路径 存储的文件路径
push:上传文件
adb push 要上传的文件路径 存储的文件路径

查看日志输出

adb logcat

查看屏幕分辨率

adb shell wm size

查看当前聚焦Activity类名

Linux系统
adb shell dumpsys activity | grep "mFocusedActivity"

Windows系统
adb shell dumpsys activity | findstr "mFocusedActivity"

模拟屏幕点击(实现微信跳一跳高分核心方法)

adb shell input touchscreen swipe x1 y1 x2 y2 time
x1:起始点击点的x位置
y1:起始点击点的y位置
x2:终止点击点的x位置
y2:终止点击点的y位置
time:操做耗时毫秒数

截屏(实现微信跳一跳高分核心方法)

adb shell screencap -p 文件输出路径