1 介绍
-
(
adb
)调试桥 -
Android SDK Platform Tools 是 Android SDK 的一个组件。它包含与 Android 平台进行交互的工具,例如
adb
、fastboot
和systrace
。开发 Android 应用时需要使用这些工具。如果您想要解锁设备的引导加载程序并为其刷入新的系统映像,同样需要使用这些工具。
2 下载
3 安装
(1)电脑端
- 【直接解压】
adb
工具不需要安装,下载下来是一个压缩文件,解压缩后是个文件夹,里面就是adb
工具所需的文件,打开即用 - 【配置环境变量】安装的根目录需要配置环境变量
(2)手机端
- 开启开发者模式 → 允许usb调试
4 操作
(1)基本命令
- 查看已连接的设备
adb devices
- 查看
adb
的版本信息
adb version
- 关闭/重启
adb
# 关闭
adb kill-server
# 重启
adb start-server
(2)锁屏/解锁/重启/关机
- 锁屏/解锁
adb shell input keyevent 26 //锁定手机
adb shell input keyevent 82 //解锁手机(如果设置了密码,会提示输入密码)
- 输入密码,并回车
adb shell input text 123456 && adb shell input keyevent 66
- 重启/关机
adb reboot //重启
adb shell reboot //重启
adb shell reboot -p //关机
(3)模拟操作
- 点击
adb shell input mouse tap 100 500
- 滑屏
adb shell input touchscreen swipe 930 880 930 380 //向上滑
adb shell input touchscreen swipe 930 880 330 880 //向左滑
adb shell input touchscreen swipe 330 880 930 880 //向右滑
adb shell input touchscreen swipe 930 380 930 880 //向下滑
(4)运行程序
- 打电话
adb shell am start -a android.intent.action.CALL -d tel:10010
- 打开网站
adb shell am start -a android.intent.action.VIEW -d http://google.com
(5)调试
- 从本地复制文件到设备,或者反之
adb push test.zip /sdcard/ //从本地复制文件到设备
adb pull /sdcard/abc.zip ~/ //从设备复制文件到本地
推送文件到设备(adb push 电脑文件路径 手机目标路径)‘push’——‘推’
在不进入设备shell的情况下,输入adb(一个空格)push(一个空格)c:\a.txt(一个空格)/sdcard/(从电脑推送a.txt文件到设备sd卡)
拉取文件到电脑(adb pull 手机文件路径 电脑目标路径)‘pull’——‘拉取’
同样在不进入设备shell下,输入adb(一个空格)pull(一个空格)/sdcard/a.txt(一个空格)c:\(从设备下载a.txt文件到电脑)
- 截屏
adb shell screencap /sdcard/a.png
……