【问题标题】:Why is MonkeyRunner failing with Bad type on operand error?为什么 MonkeyRunner 因操作数错误的错误类型而失败?
【发布时间】:2019-02-17 13:20:31
【问题描述】:

在 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)

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

【问题讨论】:

  • 您找到解决方案了吗?
  • @user3046442 不,我最终直接从 adb 推送触摸命令。我不确定我是否还有这些文件,这是针对一个自动玩一个愚蠢的 Android 游戏的愚蠢机器人项目。我很无聊:D
  • 感谢@user3046442 我的终于成功了。必须重新安装 android studio 和 SDK 工具并切换到 java 8 :) 是的,您也可以直接从 adb 发送触摸命令。

标签: android ubuntu monkeyrunner


【解决方案1】:

使用此命令安装 Android Studio:

sudo snap install android-studio --classic

之后你可以在这个路径找到“monkeyrunner”:

~/Android/Sdk/tools/bin

【讨论】:

  • 无需安装整个AndroidStudio,AndroidSDK就足够了
猜你喜欢
  • 2016-06-25
  • 2022-01-03
  • 1970-01-01
  • 1970-01-01
  • 2020-05-27
  • 2020-04-18
  • 1970-01-01
  • 2015-07-02
  • 1970-01-01
相关资源
最近更新 更多