Friday, March 16, 2012

Eclipse: working monkeyrunner configuration

This post is intended to help you if you have problems running monkeyrunner from Eclipse.
There are tons of messages floating around describing a variety of problems. It seems that the most problematic platform in this respect is Microsoft Windows, and Linux or Mac OSX are both much less tricky.


Using Android monkeyrunner from Eclipse is one of the all-time most popular post in this blog. Clearly, this indicates that the setup is not as straightforward as it should be, so I decided to post a detailed configuration that has been tested and is the one I mostly use to develop tools like AndroidViewClient, which has been described in latests posts like monkeyrunner: interacting with the Views.


After this brief introduction we are ready to start, firstly my Eclipse Helios configuration:

  •   Android DDMS 16.0.1.v201112150204-238534
  •   Android Development Tools 16.0.1.v201112150204-238534
  •   Android Hierarchy Viewer 16.0.1.v201112150204-238534
  •   Android Traceview 16.0.1.v201112150204-238534
  •   AspectJ Development Tools 2.1.3.e36x-20110622-1300
  •   Cross References tool (XRef) 2.1.3.e36x-20110622-1300
  •   EclEmma Java Code Coverage 2.0.1.201112281951
  •   Eclipse EGit 1.2.0.201112221803-r
  •   Eclipse IDE for Java Developers 1.3.2.20110301-1807
  •   Eclipse JGit 1.2.0.201112221803-r
  •   Eclipse Weaving Service Feature 2.1.3.e36x-20110622-1300
  •   Equinox Weaving SDK 1.0.0.v20100421-79--EVVFNFFsFc
  •   m2e - Maven Integration for Eclipse 1.0.100.20110804-1717
  •   m2e - slf4j over logback logging (Optional) 1.0.100.20110804-1717
  •   PyDev for Eclipse 2.2.0.2011062419
  •   Pydev Mylyn Integration 0.3.0


Following this configuration we will be using one of the AndroidViewClient's example: browser-open-url.py. This is showing its run configuration.

main

arguments

interpreter

refresh

environment

common





6 comments:

Android app development said...

This is one of the progressive and good post.I like your blog tips.Thanks for your support.Good work.
Android app developers

Unknown said...

Hi Diego,

I have configure the PyDev plugin and Imported your ViewClient project into my workspace

and then I tried to give the Python Interpreter configuration. While configuring the Interpreter with monkeyrunner.jar file i am getting below error
------------------------------------------------------------------------------------------------------------
error getting info on interpreter.

common reasons include
- using unsupported version
(Python and Jython require at least version 2.1 and Iron Python 2.6)
- Specyifiying an Invalid interpreter
(usually a link to the actual interpreter on Mac or Linux)

Reason
See error log for details
>>
See error log for details.
A jar cannot be used in order to get the info for the python interpreter.
-------------------------------
Please do the needful for this configuration issue

Diego Torres Milano said...

@a.t.obulreddy,
Is it Linux, OSX, Windows?

Unknown said...

@Diego
Windows

androidtestautomation said...

I am using below PyDev version
PyDev - 2.2.0.2011XXXXX

After importing AndroidViewClient project I am trying to run as xample level.

But I am not able to setup the PYTHONPATH in my eclipse IDE.

How you got the Default PYTHONPATH in eclipse IDE as you have mentioned in the first image.

Could you please share more information how to setup the PYTHONPATH for AndroidViewClient ?

Diego Torres Milano said...

Please check if this post helps you.

Additionally, once you have everything running but failing trying to import ViewClient you can use these line in your monkeyrunner script (I will create a post about this as well because I think it's also a common pitfall).


# PyDev sets PYTHONPATH, use it

for p in os.environ['PYTHONPATH'].split(':'):

if not p in sys.path:

sys.path.append(p)

from com.dtmilano.android.viewclient import ViewClient, View