Saturday, October 10, 2009

android-scripting: Android Scripting Environment

The Android Scripting Environment (ASE) brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device.

To install and use ASE, it's no need Eclipse as in normal development. What you need is a Android Emulator, and a AVD with SD Card installed. Personally, I prefer to generate a fresh new AVD for ASE. Refer to the article Create Android Virtual Device (AVD) in command line to create a new AVD with 1000M SD Card.

After the AVD generated, you can start Android Emulator using the new AVD:

Start Terminal, switch to the tools folder of the installed Android SDK, it's ~/android-sdk-linux_x86-1.6_r1/tools in my own setup. Type the command:
$./emulator -avd my_android1.6_for_scripting

where my_android1.6_for_scripting is the name of my AVD.

Start Browser and go to android-scripting page:
http://code.google.com/p/android-scripting/
Click the Featured downloads link, ase_r13.apk.

Or go to the link directly:
http://android-scripting.googlecode.com/files/ase_r13.apk

Click on the downloaded file, and accept Install.



After a while, the ASE will be installed. It can be found in the application list.


Click to start ASE, press MENU key start the option menu, you can Add Script, Add Interpreter, start Terminal and call Help in Browser.


In Terminal, you can type any command as in desktop Linux (Shell).


To try the examples, select Add Interpreter>Lua 5.1.4


After the files downloaded and extracted, select hello.user.lua to see the result:



You may ask, why write scripts instead of real Android applications? Admittedly, Android's development environment makes life pretty easy, but you're tied to a computer to do your work. ASE lets you develop on the device itself using high-level scripting languages to try out your idea now, in the situation where you need it, quickly. Have a look at the example Lua and Python scripts to see for yourself.

No comments: