Android 猴子跑步脚本

发布于 2024-12-06 12:37:43 字数 403 浏览 1 评论 0原文

抛出错误异常

Can't open specified script file
Usage: monkeyrunner [options] SCRIPT_FILE

    -s      MonkeyServer IP Address.
    -p      MonkeyServer TCP Port.
    -v      MonkeyServer Logging level (ALL, FINEST, FINER, FINE, CONFIG, INFO,
WARNING, SEVERE, OFF)

我正在尝试通过 Monkey runner 命令提示符执行示例 python 程序,它在线程“main”java.lang.NullPointerException 中 所以任何人都可以指导我如何解决这个问题

i am tryig to execute a sample python program through monkey runner command prompt and it is throwing an error

Can't open specified script file
Usage: monkeyrunner [options] SCRIPT_FILE

    -s      MonkeyServer IP Address.
    -p      MonkeyServer TCP Port.
    -v      MonkeyServer Logging level (ALL, FINEST, FINER, FINE, CONFIG, INFO,
WARNING, SEVERE, OFF)

Exception in thread "main" java.lang.NullPointerException
so any one can guide me how to resolve this one

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

夏末 2024-12-13 12:37:43

scriptfile 应该是完整路径文件名
尝试下面
monkeyrunner c:\test_script\first.py

scriptfile should be a full path file name
try below
monkeyrunner c:\test_script\first.py

阳光的暖冬 2024-12-13 12:37:43

尝试使用类似的东西

...\tools>monkeyrunner -v ALL first.py

,其中 first.py 是我的示例 python 脚本,我将其复制到 android SDK 的工具文件夹中(monkeyrunner.bat 所在的位置)

try using something like

...\tools>monkeyrunner -v ALL first.py

where first.py was my sample python script which I copied into tools folder of android SDK (the place where monkeyrunner.bat is located)

话少心凉 2024-12-13 12:37:43

在所有 unix/linux 系列操作系统下都可以使用 sha bang 语法。

使用以下命令的结果编辑脚本的第一行:

which monkeyrunner

例如,如果 Monkeyrunner(通常随 android sdk 提供)已安装在 /usr/local/bin/sdk 下,则写入:

#!/usr/local/bin/sdk/tools/monkeyrunner

或者甚至使用“env”

#!/usr/bin/env monkeyrunner

,然后设置您脚本文件作为可执行文件

chmod +x <script>

您现在可以从 shell 启动脚本。

Under all unix/linux families OS the sha bang syntax can be used.

Edit the first line of your script with the results of the following command:

which monkeyrunner

for example, if monkeyrunner (usually provided with android sdk) has been installed under /usr/local/bin/sdk write:

#!/usr/local/bin/sdk/tools/monkeyrunner

or even use "env"

#!/usr/bin/env monkeyrunner

then set you script file as executable

chmod +x <script>

You can now launch your script from the shell.

孤芳又自赏 2024-12-13 12:37:43

将工作目录切换到 Android SDK 文件夹看起来没有意义,而只是为了获取其自身的一些相对引用路径。这意味着您必须指定脚本文件以及要保存或比较的 PNG 图像文件的完整路径。

更好的方法是修改 SDK 文件夹下“monkeyrunner.bat”中的几行,如下所示。这将使用您当前的路径作为工作目录,因此无需使用完整路径文件名。

    rem don't modify the caller's environment
setlocal

rem Set up prog to be the path of this script, including following symlinks,
rem and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0

rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
rem cd /d %~dp0

rem Check we have a valid Java.exe in the path.
set java_exe=
call %~sdp0\lib\find_java.bat
if not defined java_exe goto :EOF

set jarfile=monkeyrunner.jar
set frameworkdir=
set libdir=


if exist %frameworkdir%%jarfile% goto JarFileOk
    set frameworkdir=%~sdp0\lib\

if exist %frameworkdir%%jarfile% goto JarFileOk
    set frameworkdir=%~sdp0\..\framework\

:JarFileOk

set jarpath=%frameworkdir%%jarfile%

if not defined ANDROID_SWT goto QueryArch
    set swt_path=%ANDROID_SWT%
    goto SwtDone

:QueryArch

    for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a

:SwtDone

if exist %swt_path% goto SetPath
    echo SWT folder '%swt_path%' does not exist.
    echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
    exit /B

:SetPath

call %java_exe% -Xmx512m -Djava.ext.dirs=%frameworkdir%;%swt_path% -Dcom.android.monkeyrunner.bindir=%frameworkdir%\..\..\platform-tools\ -jar %jarpath% %*

It looks not make sense to switch working directory to Android SDK folder but just for obtain some relative references path for itself. It means you have to specify the full path for your script file and the PNG image files you want to save or compare to.

A better way is modify few lines in the "monkeyrunner.bat" under your SDK folder as below. This will use your current path as working directory, so, no necessary to use full path file name.

    rem don't modify the caller's environment
setlocal

rem Set up prog to be the path of this script, including following symlinks,
rem and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0

rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
rem cd /d %~dp0

rem Check we have a valid Java.exe in the path.
set java_exe=
call %~sdp0\lib\find_java.bat
if not defined java_exe goto :EOF

set jarfile=monkeyrunner.jar
set frameworkdir=
set libdir=


if exist %frameworkdir%%jarfile% goto JarFileOk
    set frameworkdir=%~sdp0\lib\

if exist %frameworkdir%%jarfile% goto JarFileOk
    set frameworkdir=%~sdp0\..\framework\

:JarFileOk

set jarpath=%frameworkdir%%jarfile%

if not defined ANDROID_SWT goto QueryArch
    set swt_path=%ANDROID_SWT%
    goto SwtDone

:QueryArch

    for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a

:SwtDone

if exist %swt_path% goto SetPath
    echo SWT folder '%swt_path%' does not exist.
    echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
    exit /B

:SetPath

call %java_exe% -Xmx512m -Djava.ext.dirs=%frameworkdir%;%swt_path% -Dcom.android.monkeyrunner.bindir=%frameworkdir%\..\..\platform-tools\ -jar %jarpath% %*
感情废物 2024-12-13 12:37:43

我遇到了和你一样的事情,我通过使用工具下的“monkeyrunner”命令解决了,你的脚本文件应该是完整的路径名。看起来“tools”目录是MonnkeyRunner的主目录。我很沮丧,我无法直接通过 pydev IDE 运行我的脚本文件。

I met the same things as you did, I resolved by using "monkeyrunner" command under tools, and your script file should be a full path name. It looks like the directory “tools” is the main directory of MonnkeyRunner. I am depressed that I can't run my script files by pydev IDE directly.

浮云落日 2024-12-13 12:37:43

Monkeyrunner.bat cygpath -w $(pwd)/monkey.py

monkeyrunner.bat cygpath -w $(pwd)/monkey.py

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文