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).
- Update to newest tools (16) & platform (15) first
- Add android-sdk\tools into path
- Put foo.py into android-sdk\tools folder (it doesn't seem to work anywhere else)
- Switch usb debugging on
- Attach phone to PC
- Type "monkeyrunner foo.py"