adb常用命令
1、查看当前连接设备
adb devices

2、如果发现当前电脑连接了多台设备,通过 -s 指定设备
adb -s <指定设备的device name> <需要运行的命令>

3、获取当前界面中显示app的activity
- windows系统
adb shell dumpsys window|findstr mCurrentFocus
![]()
- mac/linux 系统
adb shell dumpsys window|grep mCurrentFocus
4、获取Android移动设备的版本信息
adb shell getprop ro.build.version.release

5、adb命令安装和卸载apk文件
- 安装与覆盖
adb install <apk文件路径(直接将文件拖到cmd内即可)> # 安装
adb install -r <apk文件路径> # 覆盖 - 查看第三方安装的包名
adb shell pm list package -3 - 根据查看到的包名进行卸载
adb uninstall <包名>
![]()
6、传递文件
- adb pull <手机路径> <电脑路径> # 将手机内的文件拉到电脑中
- adb push <电脑路径> <手机路径> # 将电脑内的文件传到手机中
![]()
7、查看包名
- adb shell pm list package -3 # 查看第三方安装的包
- adb shell pm list packages # 查看所有的包
- adb shell pm list packages -f # 查看所有的包并带有路径
8、启动activity
adb shell am start <包名>/<完整的Activity路径>

9、截图
adb shell screencap <截图存放路径>

10、屏幕事件
- 输入文字
adb shell input text "test"
adb shell input text "%s" %s代表空格 - 点击坐标
adb shell input tap <x坐标> <y坐标> - 滑动
adb shell input swipe <<X坐标> <Y坐标>> <<X偏移坐标> <Y偏移坐标>> <耗时> - 发送指令
adb shell input keyevent <指令> - 指令查看位置
/system/usr/keylayout/qwerty.kl
11、日志查询
adb logcat
Android Debug Bridge (adb) -->官⽹链接:https://developer.android.com/studio/command-line/adb




浙公网安备 33010602011771号