Why importing MonkeyRunner into Python script fails in Windows?
I created a file foo.py and copy-pasted code from the MonkeyRunner docs. The following error appears when compiling the sample code in cmd line:
Traceback (most recent call last): File "foo.py", line 2, in from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice ImportError: No module named com.android.monkeyrunner
The Android tools folder has monkeyrunner.jar... and I fail to understand how to tell Python to import classes from it.
Follow-up
I found out the error came because I didn't have the latest Android tools (16).
A) MonkeyRunner uses Jython, so you must make sure you have that installed
B) Jython must know where MonkeyRunner is. You can either have the script at the same place as where MonkeyRunner is located, or you can add it to Jython's path, so Jython will be able to find it no matter where you run the script from.