Use Trade Federation with Scripting Layer for Android

Scripting Layer for Android, SL4A, is an automation toolset for calling Android APIs in a platform-independent manner. It supports both remote automation via adb and execution of scripts from on-device via a series of lightweight translation layers.

The project is located at platform/external/sl4a.


You can follow the SL4A README to build and install it manually. And when running through Tradefed, you can take advantage of some of the harness utilities to make use easier.

Download and install

You can start by reviewing BT-discovery-sl4a.xml, an example Tradefed configuration that uses two devices. The SL4A.apk is available in most device builds within their tests folder.

The Tradefed example above automatically fetches the builds, flashes both devices and installs SL4A.apk on both devices. You can run it like so:

source build/
make sl4a run google/example/BT-discovery-sl4a

Or once built:

./ run google/example/BT-discovery-sl4a

Write a test in Tradefed using SL4A

You can follow the test sample describe above: This gives a good example of the flow to use SL4A within a Tradefed test.

SL4A API documentation

The complete list of callbacks available through SL4A can be generated. From the SL4A source directory, platform/external/sl4a/, run this command:

python Docs/

In the Docs directory there will be an file that contains the RPC functions available in SL4A, as well as documentation for the RPC functions.