Android – Automating Testing and Store Listing Screenshots with Monkeyrunner

In this tutorial we’ll be talking about Monkeyrunner and automating tasks such as preparing screenshots for Google Play Store listings.

Monkeyrunner is a high level scripting language that is capable of automating tasks such as;

  • Installing/uninstalling apps
  • Taking screenshots and saving them to your local machine
  • Sending touch events i.e. performing gestures, pressing buttons, dragging and scrolling
  • Inputting text

There are three classes in the Monkeyrunner framework these are;

  1. MonkeyRunner – Connect to devices or emulators
  2. MonkeyDevice – Represents the device you are connected to. Allows you to perform touch events, apk installations, start activities
  3. MonkeyImage – Represents the raw image captured from the device and allows you to compare images for testing

In order to run a Monkeyrunner script you need to use the monkeyrunner compiler available in the android-sdk/tools directory, rather than python to run your python code.


In here you’ll have an executable moneyrunner which you’ll need to use to run your python scripts.

Go ahead and create a new python file, lets call it, place it anywhere you’d like. Let’s start by connecting to the device, installing your APK, taking a screenshot and saving the screenshot to our current directory.

You’ll need to tell MonkeyRunner where your apk file is so that the can install the apk. You need to run your app on a device at least once for the IDE to generate you an apk file!

You can find your APK file in the following locations:
– projectFolder/yourNamespace/bin/your.apk
Android Studio
– projectFolder/yourNamespace/build/outputs/apk/your.apk

Create a py file and name it – it should look like the following;

from import MonkeyRunner, MonkeyDevice
# Connects to the first device available through the adb tool
device = MonkeyRunner.waitForConnection()
# install the APK
# declare your package name
package = 'com.your.application'
# declare your activity that you want to start
activity = 'com.your.application.MainActivity'
# prepare the whole package + activity string
activityToRun = package + '/' + activity
# start the activity above
# take a screenshot
screenshot = device.takeSnapshot()
# Writes the screenshot to a file

Place your APK file in the same directory as your py script, move into your androidsdk/tools directory and run your file in terminal.

cd into the <androidSDK>/tools
./monkeyrunner /your/path/to/

Now check out the <androidsdk>/tools folder and you should have a screenshot1.png.

MonkeyRunner Screenshot

You can also automate gestures on the phone as well as button presses, more on this in the next post.

Using the device object call press and pass in the keycode along with UP, DOWN or DOWN_AND_UP to simulate the gesture you want.'KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)

You can find the complete list of keycodes here –

Safe Places to Fly Your Drone

Drone enthusiasts are being urged to help design a new ‘safe-to-fly’ app idea, created for flyers to share their favourite sites all over the world. The creators are looking to crowdsource input and opinions to help them progress the idea, with the design stage set to start next month.

An increasing number of consumer multirotor aircraft, UAVs or drones are being bought and flown around the world. However, there is some confusion over how and where you can legally fly drones, with both manufacturers and airspace regulators keen to educate people on this issue. Users need to be aware of any prohibitions or local laws; in the UK, for example, you can’t fly over or within 150 metres of congested areas or within 50 metres of people, vehicles or structures of buildings not under your control with a camera drone.

Once it is built, the app will allow flyers to share appropriate and legal sites they have found for flying, wherever they are in the world. This will enable drone users to find easily accessible public right of ways for taking off from, beautiful scenery in open airspace and large, unobstructed areas perfect for flying.

The idea is being hosted on, a new service released by Newcastle University, which enables anyone to propose, design and develop a mobile application. No previous experience is required in app design, with the site aiming to make the process fun and simple. People can get their friends and fellow enthusiasts involved in supporting the concept and promoting the idea, which is then automatically generated by the AppMovement service and released on the Apple App Store and Google Play Store.

Simon Newton, the creator behind the idea, commented: “The drone app will help hobbyists around the world find safe and legal places to fly, by bringing together the different experiences of drone users. It is important to show the world that we don’t all buzz airports, peep into windows or fly like reckless kids!

 “We’ve had great support for the idea so far and the development will be starting soon. However in order to make this free app a success, we need a good user base with plenty of people interacting with the app. This is a great opportunity for drone lovers to be part of the development of an exciting new app, set to enhance the flying experience.”

To take part in the done app’s design phase, you must register your support at

App Movement – A new crowd commissioning platform for mobile apps

I’ve been working on a new platform,, along side some of the chaps in the lab which enables anyone to propose, design and develop a mobile application without the need to code. You can get your friends involved in supporting the idea and design it together by submitting contributions and voting on each others ideas. It’s like Kickstarter for apps and instead of money just need to get friends to show their support for the idea.

It works through a templating system which means we can quickly develop new apps with differing styles and content with a different community behind each one. At the moment you can create Location Based Review Apps – TripAdvisor style rating  apps for places worldwide. We’ve found this to be very successful and empowering to communities already in the Feed-Finder mobile app which allowed breastfeeding mothers to rate and review local business for how friendly and accepting they are of breastfeeding in public.

We’ve seen some great ideas already on the platform such as an app to find Dementia Friendly Places, Best Place to Fly Your Drone, and Gluten Free Restaurants to just name a few.

If you want to create your own mobile application visit and start your App Movement today.