How do I stop the monkey madness?

后端 未结 5 1642
無奈伤痛
無奈伤痛 2020-12-05 17:33

I\'m using the monkey tool to run a test of my Android application. For example, I might do a run like the following:

adb shell monkey -p com.myapp -v 10000         


        
相关标签:
5条回答
  • 2020-12-05 17:49
    adb shell
    ps | grep monkey
    kill process_id
    
    0 讨论(0)
  • 2020-12-05 17:53

    For what it's worth, I use Android Studio 3.1.4 on a Mac in 2018 and I had to alter the accepted answer like so:

    ./adb shell ps | awk '/com\.android\.commands\.monkey/ { system("./adb shell kill " $2) }'
    

    Hope that help prevent some hair-pulling and pencil snapping out there!

    Also... when it comes to the monkey, always be sure to pin your app!!! Otherwise you might accidentally send all your selfies to a random email in China like I did. ¯\_(ツ)_/¯

    0 讨论(0)
  • 2020-12-05 18:02

    [Nitpick] You're confusing monkeyrunner with monkey.

    The monkeyrunner tool is not related to the UI/Application Exerciser Monkey, also known as the monkey tool. The monkey tool runs in an adb shell directly on the device or emulator and generates pseudo-random streams of user and system events. In comparison, the monkeyrunner tool controls devices and emulators from a workstation by sending specific commands and events from an API.

    [/Nitpick]

    On my Android 2.2 device when I start monkey, I see a process started in DDMS by the name "?" (just a question mark). When I killed that process, the monkey madness stopped.

    0 讨论(0)
  • 2020-12-05 18:11
    adb shell kill $(adb shell pgrep monkey)
    

    kudo to @deadfish

    0 讨论(0)
  • 2020-12-05 18:13

    You can kill the monkey process just doing this:

    $ adb shell ps | awk '/com\.android\.commands\.monkey/ { system("adb shell kill " $2) }'
    
    0 讨论(0)
提交回复
热议问题