monkey是什么

/system/bin中有个monkey的shell脚本

# Script to start "monkey" on the device, which has a very rudimentary
# shell.
#
base=/system
export CLASSPATH=$base/framework/monkey.jar
trap "" HUP
exec app_process $base/bin com.android.commands.monkey.Monkey $*

/system/framework/monkey.jar

monkey命令

adb shell monkey -p com.android.test.myapplication --monitor-native-crashes --ignore-crashes --ignore-timeouts --ignore-security-exceptions --pct-touch 50 --pct-motion 50  -s 100 -v -v --throttle 200 1800000 >D:\monkey.log

如何定位crash === 测试用apk:app-crash.apk 需要将monkey命令中-p参数值调整为-p com.android.test.myapplication

  • 如果输出到一个log中,在monkeylog中,搜索“crash”或“Exception”

如何定位ANR === 测试用apk:app-anr.apk 需要将monkey命令中-p参数值调整为-p com.android.test.appanr

  • 在monkeylog中,搜索“ANR”或“NOT RESPONDING” 

如何停止monkey?

    • 确认monkey进程的pid:adb shell ps | findstr monkey
    • 杀掉monkey进程:adb shell kill 8085
01-09 20:54