一、设备连接与基础
adb devices # 查看已连接设备
adb install -r xxx.apk # 安装(-r 覆盖升级,-t 允许测试包)
adb uninstall com.xxx # 卸载
adb shell getprop ro.build.version.release # 安卓版本
adb shell wm size # 屏幕分辨率
adb reboot / adb reboot recovery # 重启 / 进 recovery
二、App 性能与状态
adb shell dumpsys activity top | findstr "ACTIVITY" # 当前前台 Activity
adb shell dumpsys meminfo com.xxx # 内存占用(观察泄漏/峰值)
adb shell top -n 1 | findstr com.xxx # CPU 占用快照
adb shell dumpsys battery # 电量(耗电测试)
adb shell dumpsys network | findstr com.xxx # App 流量
adb shell screencap /sdcard/s.png && adb pull /sdcard/s.png # 截图拉到电脑
adb shell screenrecord /sdcard/r.mp4 # 录屏(Ctrl+C 结束)
三、调试与抓包辅助
adb shell settings put global http_proxy 172.xx.xx.xx:8888 # 全局代理(指向 Charles)
adb shell settings put global http_proxy :0 # 取消代理(抓不到包先执行这个排障)
adb forward tcp:8080 tcp:8080 # 端口转发(调试本地服务)
adb shell netstat | findstr 443 # 查 App 的 443 连接状态
四、文件传输
adb push 本地文件 /sdcard/ # 电脑 → 手机
adb pull /sdcard/log.txt 本地路径 # 手机 → 电脑
五、系统级操作(root 设备可用的一部分)
adb root # adbd 提权(工程机/模拟器)
adb remount # /system 可写(改 hosts 抓包常用)
adb logcat -c # 清空旧日志(复现 bug 前先清)
adb bugreport # 完整问题报告 zip(提重型 bug 用)
六、查 SSL/握手错误
实时日志过滤 SSL 相关(Windows 用 findstr,Mac/Linux 用 grep)
adb logcat | findstr /i "ssl sslhandshake pinning trustmaster cert"
只看 App 自己的日志:先拿 PID,再过滤
adb shell pidof com.laiyifen.xxx # 换成实际包名
adb logcat --pid=<上面拿到的PID>
更省事:Android 8.0+ 只看某 App
adb logcat | findstr "包名"