blob: 425f6231430203650ecc70dade4dc062c90fc763 [file] [log] [blame] [view]
Nathan Haroldd15c7dd2016-02-17 16:42:16 -08001Scripting 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
Nathan Harold358fd412016-04-12 17:48:15 -070019*where `<ANDROID_SOURCE_ROOT>` is the root directory of the android tree and `<TARGET>` is the lunch
Nathan Haroldd15c7dd2016-02-17 16:42:16 -080020target name*
21
22Then Build SL4A:
23
tturney2d949f92016-02-24 10:26:48 -080024 cd <ANDROID_SOURCE_ROOT>/external/sl4a
Nathan Haroldd15c7dd2016-02-17 16:42:16 -080025 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"
Nathan Harold358fd412016-04-12 17:48:15 -070050*where `<HOST_PORT_NUM>` and `<DEVICE_PORT_NUM>` are the tcp ports on the host computer and device.*
Nathan Haroldd15c7dd2016-02-17 16:42:16 -080051
52### Generate the API Documentation
53From SL4A source directory run this command:
54
Randolph Chungd1dd75d2016-03-27 07:35:32 -070055 python Docs/generate_api_reference_md.py
Nathan Haroldd15c7dd2016-02-17 16:42:16 -080056
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