Raspberry-PI for Android Test Automation

At AVG Innovation Labs we are constantly experimenting and exploring new ways to solve our problems, and sometimes this results in discovering some very interesting possibilities.

One such case happened during the development of AlarmClock Xtreme, one of the most popular alarm clocks on Play Store with more than 30-million installs. To ensure good product quality before shipping, we have several automated tests in place.

The challenge? At some point during the development, we realised that some of the Android Instrumentation Tests were slowing down the build-server pipeline. This was because the tests were executed on an emulator on the build-server and could take more than 20 minutes.

Harnessing the power of Pi
To speed up things, naturally we decided to try running our automation tests on actual physical devices. But before investing in a ton of new hardware, I realised we had a number of Raspberry Pi microcomputers lying around the office.

This got me thinking perhaps we could use these as a cheap and energy efficient devices to power our tests. So we started exploring whether it was possible and if it’d even be fast enough.

Sure enough, we got something working and here’s how we did it.

rasberry pi android test automation

Figure 1: Raspberry-Pi running automated Android Tests for our Alarm Clock Xtreme app.


Setting up Pi with ADB
First make sure you have the latest Raspbian Jessie (or similar) image installed on Pi.

Then run the following commands to install ADB:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install android-tools-adb

If all goes well, try connecting an android device to the Pi with a USB. A permissions dialog should appear immediately on the device which you should allow. Then issue the command:

adb devices

If your device appears in the list (as in figure-2), then you’re ready to run android tests:

rasberry pi android test automation 2

Figure 2: Result from running adb command from PI attached to an Android device


Joining the dots between build server and Pi
Now you need to make sure that your build server can find your raspberry-pi and can connect to it. Here I will show you how to do that if you’re running a Jenkins based build server. You can create a new slave node and give it the IP-address of your PI. A sample slave node configuration is shown below.

Create a new Slave-Node in Jenkins and configure it as shown in Figure-3.

In the “Host” field make sure to give the IP-Address of your Pi. You can find that our by using the ifconfig command on your PI. In Credentials you need to give the user/password for connecting to your PI. Keep the “# of executors” field to 1 so that there is not too much load on the PI.

Don’t forget to also give the path to the “Remote root directory”, this is where your project files and newly built. apk files will be copied by Jenkins.

rasberry pi android test automation 3

Figure 3: Setting up Jenkins build-server to configure a Raspberry-Pi based slave node

Once this is set up, launch the slave agent on the Jenkins and you will see the output of the established connection and a message indicating that slave agent is running successfully.

Configuring the test-automation jobs
Next use the adb commands to install your test.apks, which are built by Jenkins, and then run the instrumentation tests. When you create a release build, along with your release .apk file which goes to the store, an extra “androidTest-unaligned” apk file is also created in the outputs/apk folder. You need to have both of them installed on your Android phone to run the tests :

adb install <your_path>-androidTest-unaligned.apk
adb install <your_path_to_release_apk>.apk
adb shell am instrument -e emma true –w <your_app_package>/android.test.InstrumentationTestRunner

If these commands run successfully on your system then, you will see on the Jenkins console the list of all the Tests which are executed and which of the Tests failed.

The Results?
The time taken to run the tests went down from 20 minutes on an emulator to under 5 minutes with a physical device attached to Pi.

This shows the Raspberry Pi is well capable of handling Android Instrumentation Tests. In comparison to an emulator running on a full system, it can also perform better with a physical device.

So not only, can you use your Pi for hobby hacking over the weekend, but it looks like people can also try it out for some serious Android development.

I’d love to hear from the developers out there. Is this something you’ve tried before? Are you planning to try it now? Leave a comment below or get in touch on Twitter. If there’s enough demand I’d like to take this idea further with 10-20 devices connected to Pi executing a lot of tests in parallel – if you’d be interested in reading about this then let us know.



Did you try this without connecting to a Jenkins server, and just using the small, cheap setup of having the test phone connected to a Pi? With the test results stored and/or displayed on the Pi?


Tanweer Ali

Hi Taryn,

Thanks for posting your question.

Jenkins server simply runs the adb shell commands that you can see above in the section “Configuring the test-automation jobs”. So yes, you can try these commands directly with a Pi.

What Jenkins helps with is in automatic build process, where when any developer within a team, commits his code to the online repository, it gets built immediately and tested by Jenkins. Also Jenkins is a free open source tool, so there is no cost involved.


Is there anything that needs to be done on Raspian other than what is outlined here? ADB works with my device on my MBP but it doesn’t list the device on Raspian.

Tanweer Ali

Hi Casey,
You need to have the “android-adb-tools” installed on the Pi.
If you have the latest image of Raspbian, this can be done using the following commands :

– sudo apt-get update
– sudo apt-get upgrade
– sudo apt-get install android-tools-adb

Once these commands are successful, then ADB will start working on the Pi.
Note, these steps are also described in the section “Setting up Pi with ADB”.

Louis Yang

I’ve done something similar but in the end it turns out many of the tools are not available for ARM so are working on Raspberry-PI. You may check it out Testude 365 (www.testude365.com), a cloud solution for enabling fully automated android device and app testing. It provides SDK so integrating automated tests into CI system is much easier.


Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.