How easy it is to create your own Android device farm on Linux

Paul Stanescu
4 min readFeb 8, 2019

Within the current post, I will try to guide you to build your device farm. The solution is based on a software called STF (Smartphone Test Farm). The guide provided on their web page is described how simple it is to use it on Mac OS. Here, I will help you to make the same thing on Linux without any additional cost.

What is a device farm

A device farm is actually a software collection which helps you test and interact, using a browser, with real Android devices. The control is remote and it allows you to install/uninstall APKs, control the device, take screenshots and also check the storage content in real time.

Prerequisite

The only thing that you must have is a Linux machine, it doesn’t matter if it is local, remote or virtual. In this example I used an Ubuntu OS instance.

Installation steps

sudo apt-get install curl

Adding the NodeSource APT repository for Debian-based distributions repository and the PGP key for verifying packages

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

Install Node.js from the Debian-based distributions repository

sudo apt-get install nodejs

Add RethinkDB key

source /etc/lsb-release && echo “deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main” | sudo tee /etc/apt/sources.list.d/rethinkdb.list

wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -

Install packages

sudo apt-get install npm

sudo apt-get update && sudo apt-get install -y git nodejs nodejs-legacy npm rethinkdb android-tools-adb python autoconf automake libtool b

Install additional packages via npm

sudo npm install -g bower karma gulp

sudo apt-get install stow

sudo apt install git-core

sudo apt install libtool

Install ZeroMQ

cd ~/Downloads && wget http://download.zeromq.org/zeromq-4.1.2.tar.gz && tar -zxvf zeromq-4.1.2.tar.gz && cd zeromq-4.1.2 && ./configure — without-libsodium — prefix=/usr/local/stow/zeromq-4.1.2

make && sudo make install && cd /usr/local/stow && sudo stow -vv zeromq-4.1.2

Install Google Protobuf

cd ~/Downloads && git clone https://github.com/google/protobuf.git && cd protobuf && ./autogen.sh && ./configure — prefix=/usr/local/stow/protobuf-`git rev-parse — short HEAD`

if you receive the error: “./autogen.sh: autoreconf: not found” run the following command:

Update library path

sudo ldconfig

If you encounter problems running the following command, please open a new terminal and re-run the command

rm –rf .node-gyp

sudo apt-get install yasm

sudo npm install -g stf -–unsafe-perm

ADB

sudo apt update

sudo apt install adb

Rethinkdb

Download it from

https://github.com/srh/rethinkdb/releases/tag/v2.3.6.srh.1

file “rethinkdb_2.3.6.srh.1.0bionic_amd64.deb”

then navigate to downloads folder and run the following commands

sudo dpkg –i rethinkdb_2.3.6.srh.1.0bionic_amd64.deb

sudo apt-get install -f

At this point, you should have all dependencies available. Now, let’s install STF software:

sudo npm install -g stf — unsafe-perm

RUN THE SOFTWARE

The expected moment is here:

rethinkdb & adb start-server

stf local

Now accessing http://127.0.0.1:7100 you should be able to access the STF server.

Everything is up and running, connect how many devices you want and play with them.

Benefits

In order to access the web interface, you have to make a login using a name and a valid email address. You will be able to see the device within the farm, the ones that are taken (busy) and the ones that are available.

The devices’ details are also available including the details about the user who is using currently the device.

Playing with them is very easy and straightforward. Even the command to connect to the current device is available on the bottom-right. All control is in your hands (actually in your mouse).

Just code it!

--

--