• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Scripting Layer For Android
2=============================
3
4### Introduction
5Originally authored by Damon Kohler, Scripting Layer for Android, SL4A, is an automation toolset
6for calling Android APIs in a platform-independent manner. It supports both remote automation via
7ADB as well as execution of scripts from on-device via a series of lightweight translation layers.
8
9### Build Instructions
10Due to its inclusion in AOSP as a privileged app, building SL4A requires a system build.
11
12For the initial build of Android:
13
14    cd <ANDROID_SOURCE_ROOT>
15    source build/envsetup.sh
16    lunch aosp_<TARGET>
17    make [-j15]
18
19*where `<ANDROID_SOURCE_ROOT>` is the root directory of the android tree and `<TARGET>` is the lunch
20target name*
21
22Then Build SL4A:
23
24    cd <ANDROID_SOURCE_ROOT>/external/sl4a
25    mm [-j15]
26
27### Adding SL4A Builds to Android Builds by Default
281) If you are not using a custom buildspec, create one as follows:
29
30        cp <ANDROID_SOURCE_ROOT>/build/buildspec.mk.default <ANDROID_SOURCE_ROOT>/buildspec.mk
31
322) Modify the buildspec to build SL4A as a custom module by editing
33    the line '#CUSTOM_MODULES:=' to 'CUSTOM_MODULES:=sl4a':
34
35        sed -i 's/#CUSTOM_MODULES:=/CUSTOM_MODULES:=sl4a/' <ANDROID_SOURCE_ROOT>/buildspec.mk
36
37### Install Instructions
38Run the following command:
39
40    adb install -r <ANDROID_SOURCE_ROOT>/out/target/product/<TARGET>/data/app/sl4a/sl4a.apk
41
42### Run Instructions
43a) SL4A may be launched from Android as a normal App; or
44b) To enable RPC access from the command prompt:
45
46    adb forward tcp:<HOST_PORT_NUM> tcp:<DEVICE_PORT_NUM>
47    adb shell "am start -a com.googlecode.android_scripting.action.LAUNCH_SERVER \
48               --ei com.googlecode.android_scripting.extra.USE_SERVICE_PORT <DEVICE_PORT_NUM> \
49               com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher"
50*where `<HOST_PORT_NUM>` and `<DEVICE_PORT_NUM>` are the tcp ports on the host computer and device.*
51
52### Generate the API Documentation
53From SL4A source directory run this command:
54
55        python Docs/generate_api_reference_md.py
56
57In the Docs directory there should now be an ApiReference.md file that
58contains which RPC functions are available in SL4A as well as documentation
59for the RPC functions.
60
61