gpt4 book ai didi

Android MonkeyRunner 异常

转载 作者:行者123 更新时间:2023-11-28 20:24:28 25 4
gpt4 key购买 nike

我正在尝试从 Eclipse (4.2) 运行 MonkeyRunner Android 测试工具。我安装了 Eclipse PyDev 插件,以及 Jython 2.5.1。我的 PyDev 解释器设置为 Jython/2.5。

我在 Eclipse 中用一个简单的 jython 文件创建了一个 Jython 项目:

# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()

现在,当我从 Eclipse 启动它时(项目 > 作为 JythonProject 运行),出现以下异常:

Traceback (most recent call last):
File "C:\svnrepository\trunk\JythonProject\src\main.py", line 10, in <module>
device = MonkeyRunner.waitForConnection()
at com.android.monkeyrunner.MonkeyRunner.waitForConnection(MonkeyRunner.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
java.lang.NullPointerException: java.lang.NullPointerException

知道哪里出了问题吗?

最佳答案

Diego Torres Milano 有一篇关于如何配置 PyDev 以将其与 monkeyrunner 一起使用的帖子。我关注了his步骤,就我而言,一切正常。

简而言之,首先您需要更改您的 Android 安装。您需要将您的 monkeyrunner 工具重命名为 monkeyrunner 原创的东西。然后,您需要在同一文件夹中编写 shell 脚本(将其命名为 monkeyrunner),它将以特定方式调用 monkeyrunner-original。

Linux 脚本:

# /bin/bash
if [ "$1" = '-u' ]
then
shift
fi

exec /opt/android-sdk-linux_86/tools/monkeyrunner-original "$@"

Windows 脚本:

REM
@echo off if("%1")==("-u") shift "C:\Program Files\Android\android-sdk\tools"/monkeyrunner-original %1 %2 %3 %4 %5 %6 %7 %8

然后在 Eclipse 中,您应该定义新的 Python 解释器(不是 Jython)并将其指向创建的脚本。

关于Android MonkeyRunner 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13251037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com