Android Monkey Command Parameters and Usage Guide
This article explains the Android Monkey tool for mobile stability testing, detailing common command‑line parameters, their effects, typical values, and provides a sample command combining these options for a short‑video application.
Android developers often use the Monkey tool to perform stability and robustness testing on mobile apps by generating pseudo‑random user events such as touches, motions, and system key presses.
1. -help Shows a brief usage summary. adb shell "monkey -help"
2. --throttle <milliseconds> Inserts a fixed delay between events; 300 ms is commonly used to mimic realistic user interaction speed. adb shell "monkey --throttle 300"
3. --pct-touch <percent> Sets the percentage of touch (down‑up) events. adb shell "monkey --pct-touch 100"
4. --pct-motion <percent> Sets the percentage of motion (drag) events; only straight‑line motions are supported. adb shell "monkey --pct-motion 100"
5. --pct-trackball <percent> Adjusts trackball events, which are rarely used on modern devices. adb shell "monkey --pct-trackball 100"
6. --pct-nav <percent> Controls basic navigation key events (up/down/left/right). adb shell "monkey --pct-nav 100"
7. --pct-majornav <percent> Controls major navigation events such as the center key, back, and menu. adb shell "monkey --pct-majornav 100"
8. --pct-syskeys <percent> Sets the proportion of system key events (Home, Back, volume, etc.). adb shell "monkey --pct-syskeys 3"
9. --pct-appswitch <percent> Determines how often Monkey starts a new Activity to cover the app’s UI. adb shell "monkey --pct-appswitch 100"
10. --pct-anyevent <percent> Adjusts the share of all other event types. adb shell "monkey --pct-anyevent 100"
11. -p <package-name> Limits testing to the specified package(s). adb shell "monkey -p com.example.app"
12. --ignore-crashes Continues testing even if the app crashes.
13. --ignore-timeouts Continues testing after ANR (Application Not Responding) errors.
14. --ignore-security-exception Ignores permission‑related exceptions and keeps sending events.
15. --kill-process-after-error Terminates the offending process when an error occurs.
16. -v Increases verbosity; up to three -v flags provide more detailed logs.
17. -s<seed> Sets the random seed so that the same event sequence can be reproduced. adb shell "monkey -s 300"
For a short‑video app that involves many swipe and tap actions, the author combines several of the above options into a single command:
adb shell "monkey -p com.xxx.video -v -v -v -s 100 --throttle 300 --pct-touch 35 --pct-motion 41 --pct-syskeys 2 --pct-appswitch 20 --pct-anyevent 2 --ignore-security-exception --ignore-crashes --ignore-timeouts 1000000" >/sdcard/xxxlog.txt 2>/sdcard/xxxlog_error.txt & logcat -v time -d >sdcard/xxx_logcat.txt
360 Quality & Efficiency
360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.