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 <module>
        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 <module>
        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?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to