Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Pull request Compare This branch is 43 commits ahead of KungPaoChicken:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Android Task runner

Automated experiment execution on Android devices


This tool is only tested on Ubuntu, but it should work in other linux distributions. You'll need:

  • Python 2.7
  • Android Debug Bridge (sudo apt install android-tools-adb)
  • Android SDK Tools (sudo apt install monkeyrunner)
  • JDK 8 (NOT JDK 9) (sudo apt install openjdk-8-jre)
  • lxml (sudo apt install python-lxml)
  • Pluginbase (pip install pluginbase)

Additionally, the following are also required for the Batterystats method:

  • power_profile.xml (retrievable from the device using APKTool)
  • (from the Android SDK Tools)
  • A device that is able to report on the idle and frequency states of the CPU using

Note: It is important that monkeyrunner shares the same adb the experiment is using. Otherwise, there will be an adb restart and output may be tainted by the notification.

Note 2: You can specifiy the path to ADB and/or Monkeyrunner in the experiment configuration. See the Experiment Configuration section below.

Note 3: To check whether the the device is able to report on the idle and frequency states of the CPU, you can run the command python -l and ensure both categories are listed among the supported categories.

Quick start

To run an experiment, run:

python android_runner your_config.json

Example configuration files can be found in the subdirectories of the example directory.



A JSON config that maps devices names to their ADB ids for easy reference in config files.

Experiment Configuration

Below is a reference to the fields for the experiment configuration. It is not always updated.

adb_path string Path to ADB. Example path: /opt/platform-tools/adb

monkeyrunner_path string Path to Monkeyrunner. Example path: /opt/platform-tools/bin/monkeyrunner

systrace_path string Path to Example path: /home/user/Android/Sdk/platform-tools/systrace/

powerprofile_path string Path to power_profile.xml. Example path: android-runner/example/batterystats/power_profile.xml

type string Type of the experiment. Can be web or native

replications positive integer Number of times an experiment is run.

duration positive integer The duration of each run in milliseconds.

devices Array<String> The names of devices to use. They will be translated into ids defined in devices.json.

paths Array<String> The paths to the APKs/URLs to test with.

browsers Array<String> Dependent on type = web The names of browser(s) to use. Currently supported values are chrome.

profilers JSON A JSON object to describe the profilers to be used and their arguments. Below are several examples:

  "profilers": {
    "trepn": {
      "sample_interval": 100,
      "data_points": ["battery_power", "mem_usage"]
  "profilers": {
    "android": {
      "sample_interval": 100,
      "data_points": ["cpu", "mem"]
  "profilers": {
    "batterystats": {
      "cleanup": true

cleanup boolean Delete log files required by Batterystats after completion of the experiment. The default is true.

scripts JSON A JSON list of types and paths of scripts to run. Below is an example:

"scripts": {
  "before_experiment": "",
  "before_run": "",
  "interaction": "",
  "after_run": "",
  "after_experiment": ""

Below are the supported types:

  • before_experiment executes once before the first run
  • before_run executes before every run
  • after_launch executes after the target app/website is launched, but before profiling starts
  • interaction executes between the start and end of a run
  • after_run executes after a run completes
  • after_experiment executes once after the last run

Detailed documentation

The original thesis can be found here:

The thesis regarding the implementation of Batterystats can be found here:


Devices have no permissions (udev requires plugdev group membership)

This happens when the user calling adb is not in the plugdev group.


sudo usermod -aG plugdev $LOGNAME


[Batterystats] IOError: Unable to get atrace data. Did you forget adb root?

This happens when the device is unable to retrieve CPU information using


Check whether the device is able to report on both categories freq and idle using Systrace:

python -l

If the categories are not listed, use a different device.


You can’t perform that action at this time.