注:文中 "[ip] ,[包名],[apk路径]"等位置整体替换。
adb shell install -g MyApp.apk
adb devices
//查看Ip地址
adb shell ifconfig | grep Mask
//设置端口号
adb tcpip 5555
无线连接adb
adb connect [ip]:5555
//断开连接
adb disconnect [ip]:5555
//安装(升级或者同级覆盖安装)
adb install -r [apk路径]
//允许降级安装
adb install -d [apk路径]
adb uninstall [包名]
adb shell pm clear [包名]
adb shell am force-stop [包名]
adb shell am start -n com.android.settings/.Settings
adb shell pm list packages xxxx
adb shell dumpsys package | grep xxxx
adb shell dumpsys package com.android.settings
adb shell dumpsys package com.android.settings | grep version
adb pull [设备里的文件路径] [电脑上的目录]
adb pull data/anr/ /Desktop
adb push /Desktop/xxx.png /sdcard/
adb shell input tap 50 50
adb shell input keyevent [keycode]
keycode | 含义 |
---|---|
3 | centered HOME 键 |
4 | 返回键 |
5 | 打开拨号应用 |
6 | 挂断电话 |
24 | 增加音量 |
25 | 降低音量 |
26 | 电源键 |
27 | 拍照(需要在相机应用里) |
64 | 打开浏览器 |
82 | 菜单键 |
85 | 播放/暂停 |
86 | 停止播放 |
87 | 播放下一首 |
88 | 播放上一首 |
122 | 移动光标到行首或列表顶部 |
123 | 移动光标到行末或列表底部 |
126 | 恢复播放 |
127 | 暂停播放 |
164 | 静音 |
176 | 打开系统设置 |
187 | 切换应用 |
207 | 打开联系人 |
208 | 打开日历 |
209 | 打开音乐 |
210 | 打开计算器 |
220 | 降低屏幕亮度 |
221 | 提高屏幕亮度 |
223 | 系统休眠 |
224 | 点亮屏幕 |
231 | 打开语音助手 |
276 | 如果没有 wakelock 则让系统休眠 |
adb shell input swipe 300 300 500 500
adb shell input text hello
adb logcat [过滤]
例如: adb logcat ":W"
adb logcat -c
adb shell getprop ro.product.model
adb shell wm density
adb shell wm size
//-p 指定保存文件为 png 格式
adb shell screencap -p /sdcard/sc.png
adb shell screenrecord /sdcard/filename.mp4
adb shell ps
adb shell top
adb shell dumpsys package [包名] | grep userId=
adb shell ps | grep monkey
adb shell kill [进程Id]
常用命令参考
常用命令大全
Monkey测试相关命令