一般日志:(先输入命令,再重现问题)
adb logcat -v time >自己的保存的路径+要保存的文件名字
adb shell logcat >D:\SDK\log.txt
注意路径中的空格,命令输入完后一定要重现问题。
adb devices 查看链接模拟器
adb version 查看版本号
adb
connect 127.0.0.1:21503 链接模拟器
127.0.0.1:62025 第二个
127.0.0.1:62026第三个
adb shell进入设备底层命令 Linux
adb -s指定设备号shell 进入该设备的底层命令
# exit 退出底层命令
adb install 文件路径
adb install -r文件路径 覆盖安装
adb -s 127.0.0.1:62025 install指定模拟器安装
查看包名1、adb shell
2、cd
/data/app/
3、ls
4、查看对应的包名。
5、exit。
卸载app
adb uninstall 包名
adb kill -server 关闭adb服务
adb start -server开启adb服务
如果5037端口被占用
1、netstat -ano | findstr”5037”
2、taskkill -f -pid xxx
获取app Activity
aapt dump badging文件路径
aapt dump badging包名 | findstr“launchable
activity” 筛选出
monkey 参数
常规参数
1、帮助类参数 adb shell
monkey -h
2、日志级别 0级:adb shell monkey
-v 200(常用)
1级adb shell monkey -v -v 200(常用)
2级adb shell monkey -v -v -v 200
事件类参数
1、执行指定的脚本
adb shell monkey
-f脚本名称
2、伪随机数生成种子值
adb shell monkey -s伪随机数 执行数 (伪随机数随意设,可以加打印日志)
3、设置间隔 (--throttle)
adb shell monkey –throttle 间隔几秒(单位毫秒) 执行次数 (可加打印日志参数)
4、调试触摸事件百分比
(--pct-touch)
adb shell monkey --pct-touch 百分比
执行数 (可加打印日志参数)
5、调整手势事件百分比(--pct-motion)
adb shell monkey -- pct -motion 百分比 执行数 (可加打印日志参数)
6、调整应用启动事件的百分比(--pct-appswitch)
adb shell monkey
-- pct - appswitch百分比 执行数 (可加打印日志参数)
7、调整屏幕旋转事件百分比(--pct-rotation)
adb shell monkey --
pct - rotation百分比 执行数 (可加打印日志参数)
事件百分比 命令
1 | --pct-touch | 触摸事件百分比 | |
2 | --pct-motion | 动作事件百分比 | |
3 | --pct-trackball | 轨迹球事件百分比 | |
4 | --pct-nav | 基本导航事件百分比 | |
5 | --pct-majornav | 主要导航事件百分比 | |
6 | --pct-syskeys | 系统按键事件百分比 | |
7 | --pct-appswitch | 应用启动事件百分比 | |
8 | --pct-anyevent | 其他类型事件百分比 | keypress |
9 | | | 不常用的button |
10 | | | 其他未提及事件 |
指定包monkey测试
adb shell monkey -p包名 执行数{可加一系列参数(-v日志 -s伪随机数–pct-xxxx 事件百分比)}
例如:adb shell
monkey -v -s 999 –pct-touch 50 -p包名 执行数
可执行多个包进行monkey测试
例如:adb shell monkey -p包名-p包名 执行数
activity类约束(一般不用,都是默认)
例如:adb shell monkey -c Inten CATEGORY_LAUNCHER 执行数
调试类参数
1、应用崩溃后继续发送事件(--ignore-crashes)
adb shell money --ignore-crashes
发生崩溃后继续执行
2、超时错误继续发送事件(--ignore-timeouts)
adb shell monkey --ignore-timeouts
发生超时后继续执行
3、应用程序权限错误发生后继续发生事件(--ignore-security-exceptions)
Adb shell monkey --ignore-security-exceptions
继续执行
Monkey调用测试命令 |
--dbg-on-events | 监视应用程序所调用的包之间的转换 |
--hprof | 在事件序列前后立即生成profiling report |
--ignore-crashes 出错继续事件 | 应用崩溃后继续发送事件 |
--ignore-timeouts 出错继续事件 | 超时错误继续发送事件 |
--ignore-security-exceptions出错继续事件 | 应用程序权限错误发生后继续发生事件 |
--kill-process-after-error | 在应用程序出错后通知系统停止发生错误的进程 |
--monitor-native-crashes | 监视并报告monkey运行时Android系统native
code的崩溃事件 |
--wait-dbg | 暂停执行中的monkey,直到有调试器与它连接 |