3.9. Installing Squish for Android

Table of Contents

3.9.1. Make the Android app testable

Squish can be used to test software for Android that meets the following prerequisites:

  1. The application must provide a user interface.

  2. From the application, a test package has to be made and installed.

For the second prerequisite, a JavaJDK, version 7 or higher, and optionally the Android SDK has to be installed.

With the prerequisites in place, Squish can be used to test the application, either using an Android emulator or using an Android device connected to the machine running Squish via USB.

[Warning]OS-level changes for >= Android-28

For finding some UI elements, Squish has to use Java™ reflection in some cases. These code paths may break in future, yet unsupported, Android versions. Therefore since Android-28 (Android Pie), a warning dialog informs the user about this access. Of course that breaks UI testing and therefore Squish disables warnings dialogs, but keep warnings in the log (the logcat output).


When testing on a real device using USB on MS Windows, a special USB driver (for development/debugging purposes) from the vendor of the specific Android device/model must be installed (see OEM USB Drivers, the fact that an Android device shows up as a usable device in the operating system is usually not sufficient).


Linux users testing on a real device using USB should make sure the access permissions to the device are configured properly (see Using Hardware Devices).

3.9.1. Make the Android app testable

Squish can record and replay test scripts for your application when there is a package containing the SquishHook instrumentation that has the target set to your application's package name. Using a separate test package

This is the method used by the Squish IDE. The IDE will build a test apk, re-sign your apk and finally install both. Either when choosing a new package in the test suite settings page or Manage Android AUTs in the Server Settings.

For command-line users, to create a test package, re-sign yours and install, run

apk-tool -a <path-to-android-sdk> -j <jdk> -pkg <your-apk> -o <temp-dir> -d <device>

where apk-tool is a script found in the Squish' bin directory, jdk the full path to a JavaJDK, version 7 or higher, and temp-dir some directory where apk-tool writes some temporary files.

The -a option may be omitted. Squish has the required tools packed. Use it when your app uses more up-to-date resources from the Android SDK.

The -j option may be omitted when both java and jarsigner are in your path.

You can pass multiple -d device pairs to the apk-tool.


The packages installed by apk-tool may conflict with a previous installed package due to re-signing. Either uninstall it manually first or edit the apk-tool script Settings for Signing field to match the keystore and credential your apk is using. Using a built-in SquishHook

This is an alternative method to get a testable application. Instead of creating a test apk, the squish hook can be built-in too. This may be a faster compile/test cycle in some work loads.

We take as example AddressBook, which you can find in the android directory under examples.

This project was created as

$ android-sdk/tools/android create project --target android-8 \
    --name AddressBook --path AddressBook \
    --activity AddressBook --package com.froglogic.addressbook

To compile this application yourself, first create a local.properties file containing



When on MS Windows, either use forward slashes or use double backslashes for the path.

Next, create a project.properties file containing



Look in your Android SDK directory for the possible targets. The targets are the subdirectories under android-sdk/targets/. Here we use target android-8.

Then create a libs subdirectory and copy the file squishandroid.jar in there.

To add support for UiAutomation, also the jars testing-support-lib and uiautomator can be copied to libs. These two jars can be retrieved from the Android-SDK extras/android/m2repository/com/android/support/test directory, when having 'Android Support Repository' installed. Unzip the aar files and rename classes.jar so that these two jars don't overwrite each other.

Edit the AndroidManifest.xml file to enable Squish instrumentation.

Edit the AndroidManifest.xml file to add android.permission.INTERNET permission.


The above two steps have been done for the AddressBook application already

To build the application, execute

$ ant debug

Start the device or emulator, and once it is ready, install the application by executing

$ android-sdk/platform-tools/adb install -r bin/AddressBook-debug.apk

Naturally, you must replace android-sdk with the full path to your Android SDK installation.  Starting the AUT

For more information of starting the application in a test script, see Notes on using startApplication with Android (Section 5.12.2)

You can check to see if Squish can see multiple devices and emulators by executing:

squishrunner --info androidDevices

To see all applications that Squish can use, run

squishrunner --info androidInstrumentation

squishserver must be running to handle the --info request.