Reprint: Monkeyrunner's eclipse in the environment of running Monkeyrunner scripts (iv)

Source: Internet
Author: User

Reproduced from:lYnnli Monkeyrunner in Eclipse Run the Monkeyrunner script Environment Building (iv)

The Monkeyrunner script is written in Python syntax, but it actually interprets execution through Jython. Jython is a Python Java implementation that interprets Python code as a bytecode on a Java virtual machine and executes it, which allows you to inherit a Java type from Python and invoke any Java API.

This document is primarily capable of running Monkeyrunner scripts in an eclipse environment. The environments and tools you need are as follows: Win7 OS, JDK, Eclipse, SDK, Python, Jython, emulator, or real machine device.

In the first two chapters, we have separately configured the Android development environment in Eclipse, Monkeyrunner environment. The above tools are basically available, with Jython in Sdk\tools\lib. So, in this document, we just need to integrate monkeyrunner and python into eclipse so that we can debug and run the Monkeyrunner script in eclipse later.

1.PyDev Plug-in installation

On the Install page, click the Add button to go to the Add Repository page.

On the Add Repository page, enter the name and address of the plugin you want to get, where the address must be entered correctly. Since we are going to get pydev, here is the name Pydev, the address is Pydev:

HTTPS://DL.BINTRAY.COM/FABIOZ/PYDEV/5.1.2/(original address: Http://pydev.org/updates)

After clicking the OK button, go to the Pydev loading page:

After the Pydev is loaded successfully, select Pydev to download.

After that, follow the prompts on the page, next, finish the download and install the last finish.

2.Jython Development Environment Configuration

Window-preferences-pydev-python interpreter, new a Python interpreter, path Select your Python.exe, click OK.

Following the page prompts, the configuration of the Jython environment begins after the loading is complete.

Window-preferences-pydev-jython interpreter, new one Jython, path selection sdk\tools\ Jython-standalone-2.5.3.jar, click OK.

If the load results are as follows:

Copy the entire LIB file in Python to the Jython-standalone-2.5.3.jar directory in the SDK Tools\lib, again new Jython, Add the Jython-standalone-2.5.3.jar path. Or choose proceed anyways directly.

When the load is complete, click Apply-ok, which completes the Jython environment configuration.

3.Monkeyrunner Development Environment Configuration

So far we've configured Jython's development environment, and we can already create a Jython project. However, we have not completed the Monkeyrunner configuration, so now the Jython project is not very convenient to develop Monkeyrunner.

In fact, building monkeyrunner development environment is to add the package we need to Jython pythonpath inside, convenient for us to refer directly.

In Window-preference-pydev-jython interpreter, click on the "New jar/zips" button on the right to start selecting the Jar package you need to use under \tools\lib below your SDK. Here are the jar packages we need this time: Hierarchyviewer2.jar, Hierarchyviewer2lib.jar, Monkeyrunner.jar, Chimpchat.jar, adding these jar packages in turn.

The last page to load successfully is as follows:

To this end, the Monkeyrunner environment configuration is complete.

4.Jython Project Creation

Once the environment has been built, we can create a new Jython project. Below we create a Jython project.

In file, new a project, and select Pydev project.

According to the requirements, fill in the project name and select the type of project for Jython, click Finish.

After the project is newly created, click on the selected item, right, new Pydev Module, after the new completion, you can write the Python program.

Now, we have copied the script written in Monkeyrunner directly into Eclipse, the new Pydev module, including the Guide package, connecting the device, installing the app, launching the app:

Import monkeyrunner,monkeydevice device=monkeyrunner.waitforconnection () device.installpackage ('F : \\QQ_374.apk') device.startactivity (component="com.tencent.mobileqq/.activity. Splashactivity")        

Actually executing this code requires Android-provided monkeyrunner.bat, so you can't run the program as you normally would, so configure the Monkeyrunner script in Eclipse to run.

Run Monkeyrunner script in 5.Eclipse

Select Run-external tools-external Tools configurations in the menu bar,

Add related configuration information, such as:

Note: The above configuration is for test02.py only, if there is a new Pydev package, change the configuration of working directory and arguments at the same time.

After the simulator is started, you can then run the new Pydev module that you just created.

On the simulator, we can see the automatic installation and launch of the app. This means that the environment is already configured successfully, and then you can edit the Monkeyrunner script in Eclipse and run it.

Run Monkeyrunner scripts in 6.eclipse, problems and Solutions run the Moneyrunner script in Eclipse, error: The software in your console aborted an established connection workaround: 1.kill Process Adb.exe,1) View Adb.exe process number XXXtasklist | findstr adb.exe2) Kill the processtaskkill/f/t/im xxx2. Then restart eclipse,3. Open Adb.exe, connect device 1) Open CMD2) connection simulator adb connect IP

Reprint: Monkeyrunner's eclipse in the environment of running Monkeyrunner scripts (iv)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.