ADB(Android Debug Bridge)是安卓调试桥,能做卸载预装、传文件、截图、装应用等几乎所有事。
安装
Windows
下载 Google 官方的 Platform Tools,解压到 C:\platform-tools,然后把该目录加入系统环境变量 Path。
验证:
adb version
macOS / Linux
# macOS
brew install android-platform-tools
# Ubuntu / Debian
sudo apt install android-tools-adb
连接设备
有线连接:
adb devices
无线连接(安卓 11+,需先配对):
adb pair 192.168.1.100:37000
adb connect 192.168.1.100:5555
20 个常用命令
应用管理
| 命令 | 作用 |
|---|---|
adb install app.apk |
安装应用 |
adb install -r app.apk |
覆盖安装 |
adb uninstall 包名 |
卸载应用 |
adb shell pm list packages |
列出所有包名 |
adb shell pm clear 包名 |
清除应用数据 |
文件传输
| 命令 | 作用 |
|---|---|
adb push 本地路径 /sdcard/ |
电脑 → 手机 |
adb pull /sdcard/文件 本地路径 |
手机 → 电脑 |
截图与录屏
# 截图
adb shell screencap -p /sdcard/s.png
adb pull /sdcard/s.png
# 录屏(最多 180 秒)
adb shell screenrecord /sdcard/v.mp4
系统操作
| 命令 | 作用 |
|---|---|
adb reboot |
重启 |
adb reboot recovery |
重启到 Recovery |
adb shell input text "hello" |
模拟输入文字 |
adb shell input keyevent 26 |
模拟电源键 |
adb logcat |
查看日志 |
adb shell dumpsys battery |
查看电池信息 |
常见问题
Q:设备显示 offline?
A:重启 adb 服务:adb kill-server 然后 adb start-server。
Q:命令提示 more than one device?
A:用 -s 设备序列号 指定,例如 adb -s ABC123 shell。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END










暂无评论内容