Adb Command

查看所有当前所有进程命令: adb shell ps

列名含义
USER所属用户
PID Process ID进程 ID
PPID Process Parent ID父进程 ID
VSIZE Virtual Size进程的虚拟内存大小
RSS Resident Set Size实际驻留”在内存中”的内存大小
WCHAN休眠进程在内核中的地址
NAME进程名
  • 在 Windows 上筛选某个进程:adb shell ps|findstr baidu
  • 在手机上筛选某个进程:adb shell ps baidu 或者 adb shell ps|findstr -i baidu
  • android 或者 linux 中的 shell 命令是 grep:adb shell ps|grepbaidu

指定设备安装 apk

1
2
adb -s "设备id" install app-release.apk
"覆盖安装" adb install -r app-release.apk

卸载 Apk

1
adb uninstall com.example.android.backgraound

检测端口是否被占用

1
netstat -a -o -n | find "34999"

杀掉进程

1
taskkill /f /pid (进程 Id 44468)

调试打开某个应用

1
adb forward tco:34999 localabstract:Unity-com.xxx.xx

包信息查询

1
"子命令格式" adb shell dumpsys package [-h] [-f] [—checkin] [cmd] ...

Activity 信息查询

1
"子命令格式" adb shell dumpsys activity [-a]  [-c] ...

网络信息查询

1
2
3
4
"网络连接" adb shell dumpsys connectivity
"网络策略" adb shell dumpsys netpolicy
"网络状态" adb shell dumpsys netstats
"网络管理" adb shell dumpsys network_management

其他常用服务信息查询

1
2
3
4
5
6
7
8
9
10
"内   存" adb shell dumpsys meminfo
"处理 器" adb shell dumpsys cpuinfo
"帧 率" adb shell dumpsys gfxinfo
"显 示" adb shell dumpsys display
"电 源" adb shell dumpsys power
"电池状态" adb shell dumpsys batterystats
"手机电量" adb shell dumpsys battery set level 100
"电 池" adb shell dumpsys battery
"闹 钟" adb shell dumpsys alarm
"位 置" adb shell dumpsys location

显示连接到的计算机的设备

1
adb devices

多设备连接时指定操作设备

1
adb -s "设备SN" "Cmd"

PC 传文件到 Android

1
adb push ./thing.zip /storage/sdcard0/

PC 获取 Android 文件

1
adb pull /storage/sdcard0/thing.zip ./

启动指定 App 的指定 Activity

1
2
adb sehll am start -n
com.android.settings/com.android.settings.Settings

关闭指定 App

1
adb shell am force-stop com.android.settings

清除指定 App 数据

1
adb sehll pm clear com.example.android.background

查看第三方应用

1
adb shell pm list pckages -3

模拟器手机从 USB Android 6.0 以上

1
2
3
"拔掉USB" adb sehll dumpsys battery unplug
"重新插上" adb shell dumpsys battery reset
"切换非充电模式" adb sell dumpsys battery set status 1