Monkey
下载安装好Android_SDK就可以使用monkey了。
1.进入目录AndroidSDK\Android_SDK_windows\platform-tools
2.打开Android模拟器:emulator –avd 模拟器名称
3.adb shell 进入shell界面
exit退出shell界面
4.查看应用程序包
ls data/data
5.执行monkey
monkey -p 程序包名 -v 1000 monkey -p com.android.calculator2 -v 1000 (shell界面命令)
adb shell monkey -p com.android.calculator -s 10 -v 1000 (window命令) -s 指定seed值 -v 反馈信息级别 -p 指定包
adb shell monkey -p com.android.calculator -s 10 -v 1000 > C:\monkey\test.txt 保存日志
adb shell monkey -p com.android.calculator --throttle 500 -s 100 -vvv 10000 > C:\monkey\test1.txt --throttle 用户操作延时
6.停止monkey
执行过程中干掉monkey进程:进入shell,ps|grep monkey,kill monkey进程
7.分析日志
无响应问题可以在日志中搜索 “ANR” ,崩溃问题搜索 “CRASH” ,内存泄露问题搜索"GC",异常问题搜索 “Exception”(如果出现空指针, NullPointerException),搜到之后往前找到switch,看哪个activity出的问题(component)
8.指定activity执行
adb shell am start 程序包名/Activity名 先指定开始的activity,am---activity manager,可以模拟各种系统的操作
adb shell monkey -p 程序包名 --throttle 500 -s 100 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes --pct-appswtich 2 -vvv 10000 > C:\monkey\test1.txt
--pct-appswtich 2 切换activity的百分比