0

On Ubuntu 18.04, I installed MonkeyRunner via sudo apt install monkeyrunner, and it completed successfully.

I created a file called test.py and wrote the content

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

I connected my phone over USB, enabled USB debugging, then executed the program with monkeyrunner test.py but I get this error

Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    com/android/monkeyrunner/ScriptRunner.console(Ljava/lang/String;)V @13: invokevirtual
  Reason:
    Type 'org/python/util/JLineConsole' (current frame, stack[0]) is not assignable to 'org/python/util/InteractiveConsole'
  Current Frame:
    bci: @13
    flags: { }
    locals: { 'java/lang/String', 'org/python/util/JLineConsole' }
    stack: { 'org/python/util/JLineConsole' }
  Bytecode:
    0x0000000: 2ab8 0035 bb00 5159 b700 524c 2bb6 0053
    0x0000010: b1                                     

    at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:73)
    at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189)

What is causing this, and how can I resolve this?

Yanick Rochon
  • 51,409
  • 25
  • 133
  • 214
  • Did you find a solution for this? – user3046442 Mar 09 '20 at 08:54
  • @user3046442 no, I ended up pushing touch commands directly from adb. I'm not sure if I still have the files though, this was for a dumb bot project auto-playing a dumb Android game. I was bored :D – Yanick Rochon Mar 09 '20 at 17:56
  • Thanks @user3046442 mine finally worked. Had to reinstall android studio and SDK tools and switched to java 8 :) And yes you can directly send touch commands from adb as well. – user3046442 Mar 13 '20 at 11:42

1 Answers1

0

Install Android studio with this command:

sudo snap install android-studio --classic

After that you can find "monkeyrunner" at this path:

~/Android/Sdk/tools/bin
0v3rl04d
  • 33
  • 1
  • 7