1. 检查连接
adb devices -l
2. 开启、关闭adb服务
adb start-server
adb kill-server
3.查看adb出了什么问题
adb nodaemon server
4.doc下查询端口进程
netstat -ano | findstr "端口"
tasklist | findstr “8516”
C:\Users\lizy>taskkill /f /pid 963
5. 查看apk的launcherActivity
adb shell dumpsys activity | findstr “mResume”
6.禁用状态栏(避免自动开启飞行模式或断网)
adb shell settings put global policy_control immersive.full=*
7.恢复状态栏
adb shell settings put global policy_control null
8.查找当前系统中所有的安装包以及路径
adb shell pm list package -f 模糊包名
9.安装apk
adb -s devicename install packagename(a.apk包名)
10.覆盖安装 加 -r
adb -s 指定连接的手机 install -r 指定安装包路径
11.卸载应用
adb -s 127.0.0.1:62001 uninstall com.wandoujia.phoenix2(已经安装好的package名)
12.冷热启动语法
#冷启动语法:(热启动也是同一个指令,但是不关闭应用,挂在后台)
adb shell am start -W [packageName]/[packageName.MainActivity]
#每次执行都是冷启动
adb shell am start -W -S [packageName]/[packageName.MainActivity]
package/activity:
com.miui.calculator/com.miui.calculator.cal.CalculatorActivity
#冷启动
adb shell am start -W com.miui.calculator/com.miui.calculator.cal.CalculatorActivity
adb shell am start -W -S com.miui.calculator/com.miui.calculator.cal.CalculatorActivity
#冷启动的停止
adb shell am force-stop com.miui.calculator
#热启动的停止 ---3代表的是手机上的back返回键
adb shell input keyevent 3
APP性能监控:
1.查看CPU信息
adb shell dumpsys cpuinfo
adb shell dumpsys cpuinfo | findstr com.miui.calculator
2.动态查看CPU占用最高的5个进程
adb shell top -m 5
3.查看内存信息
adb shell dumpsys meminfo 包名或pid
4.获取电量命令
adb shell dumpsys battery
adb monkey
Android基本事件百分比(11个事件的总和是100%)
0:触摸事件百分比 参数--pct-touch
1:滑动事件百分比 参数--pct-motion
2:缩放事件百分比 参数--pct-pinchzoom
3:轨迹球事件百分比 参数--pct-trackball
4:屏幕旋转事件百分比 参数 - -pct-rotation
5:基本导航事件百分比 参数 --pct-nav
6:主要导航事件百分比 参数--pct-majornav
7:系统事件百分比 参数--pct-syskeys
8:Activity启动事件百分比 参数--pct-appswitch
9:键盘翻转事件百分比 参数--pct-flip
10:其他事件百分比 参数--pct-anyevent
adb shell monkey -p 包名 --throttle 200 --pct-touch 60 --pct-pinchzoom 40 -v -v -v 10000 >d:\20200717_monkeylog.txt
简单用法:
-v 代表日志详细等级
-p 指定包名
-s 识别码(用于复现问题)
adb shell monkey -p 包名 -v-v-v 2000
终止运行中的monkey:
ps | grep monkey
kill pid