猴子跑者的问题
我正在努力对 android 框架层进行一些更改并构建我自己的版本。我正在基于 froyo 工作并尝试使用 Monkeyrunner 进行一些测试。我已经提取了源代码,可以在模拟器中构建和运行,但是当我尝试使用 Monkeyrunner 脚本时,我似乎无法进行任何工作。我使用 Lunch full-eng 构建了代码,它在设备上运行良好。我只是想根据 http:// 中的示例运行一个简单的脚本下面显示了developer.android.com/guide/developing/tools/monkeyrunner_concepts.html,添加了一条打印语句,只是为了看看我是否可以运行任何东西。
/# 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()
print "Hello World!"
当脚本中包含以下行时,我收到如下错误。
从 com.android.monkeyrunner 导入 MonkeyRunner、MonkeyDevice
回溯(最近一次调用最后一次): 文件“../../MRTesting/MyTest.py,第 4 行,位于 从 com.android.monkeyrunner 导入 MonkeyRunner、MonkeyDevice 导入错误:无法导入名称 MonkeyDevice
因此,如果我从导入中删除 MonkeyDevice(如下所示),我会在调用 waitForConnection() 时收到不同的错误
从 com.android.monkeyrunner 导入 MonkeyRunner
回溯(最近一次调用最后一次): 文件“../../MRTesting/MyTest.py,第 6 行,位于 设备 = MonkeyRunner.waitForConnection() AttributeError:类型对象“com.android.monkeyrunner.MonkeyRunner”没有属性“waitForConnection”
我尝试修改调用以具有文档中所示的一些参数,如下所示,但我仍然收到相同的错误。第二个参数与调用 adb devices 返回的值匹配。
device = MonkeyRunner.waitForConnection(5, 'emulator-5554')
我做了一些挖掘,有人说 shebang 需要位于文件的开头,如下所示,并修改路径以避免将我不想共享的信息放入其中。
/#! /home/<path>/monkeyrunner
我看不出这与我直接从命令行调用 Monkeyrunner 有什么不同,但我尝试了,但没有成功。我没有在系统上的任何地方安装 SDK,因为它包含在构建树中,但在我看来,monkeyrunner 工具可能无法根据需要找到它,但我找不到任何有关如何解决此问题的指示。当我从根目录的构建目录中构建系统时,我正在运行以下命令。
. build/envsetup.sh
setpaths
lunch full-eng
make -j16
有人对此有什么想法吗?
I am working on making some changes to the android framework layer and building my own version. I am working based on froyo and trying to use monkeyrunner for some testing. I have pulled the source and can build and run in the emulator but when I try to use a monkeyrunner script I can't seem to get anyhting to work. I built the code using lunch full-eng and it runs fine on the device. I am just trying to get a simple script running based on the example at http://developer.android.com/guide/developing/tools/monkeyrunner_concepts.html shown below with a print statement added just to see if I could get anything to run.
/# 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()
print "Hello World!"
When the following line is in the script I get an error as follows.
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
Traceback (most recent call last):
File "../../MRTesting/MyTest.py, line 4, in
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
ImportError: cannot import name MonkeyDevice
So if I remove MonkeyDevice from the import as shown below I get a different error on the call to waitForConnection()
from com.android.monkeyrunner import MonkeyRunner
Traceback (most recent call last):
File "../../MRTesting/MyTest.py, line 6, in
device = MonkeyRunner.waitForConnection()
AttributeError: type object 'com.android.monkeyrunner.MonkeyRunner' has no attribute 'waitForConnection'
I tried modifying the call to have some arguments as indicated in the documentation as follows but I still get the same error. The second argument matches the value returned by a call to adb devices.
device = MonkeyRunner.waitForConnection(5, 'emulator-5554')
I have done some digging around and one person said that the shebang needs to be at the beginning of the file as follows with the path modified to avoid putting information in I would rather not share.
/#! /home/<path>/monkeyrunner
I could not see how this would be any different than me invoking monkeyrunner directly from the command line but I tried it and no luck. I did not install the sdk anywhere on my system as it is included in the build tree but it seems to me that the monkeyrunner tool might not be able to locate it as needed but I can't find any indication of how to fix this. I am running the following commands when I build my system from within my build directory at the root.
. build/envsetup.sh
setpaths
lunch full-eng
make -j16
Anyone have any thoughts on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论