为什么MonkeyRunner在操作数错误时出现Bad type失败?

时间:2018-09-12 20:28:44

标签: android ubuntu monkeyrunner

在Ubuntu 18.04上,我通过sudo apt install monkeyrunner安装了MonkeyRunner,并成功完成了

我创建了一个名为test.py的文件并编写了内容

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

我通过USB连接手机,启用了USB调试功能,然后使用monkeyrunner test.py执行了程序,但出现此错误

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)

是什么原因造成的,我该如何解决?

1 个答案:

答案 0 :(得分:1)

使用以下命令安装Android Studio:

sudo snap install android-studio --classic

之后,您可以在以下路径中找到“ monkeyrunner”:

~/Android/Sdk/tools/bin