SL4A - Scripting Layer for Android

Android scripting is a handy tool for simple tasks such as automation and prototyping as against using the Java programming language for the same. The Scripting Layer for Android (SL4A) provides a platform for multiple scripting solutions on the android platform.

What is SL4A?

The Scripting Layer for Android (SL4A) is a library that provides a platform to write simple scripts to automate tasks on an android device using languages other than JAVA.

SL4A, originally called Android Scripting Environment (ASE), was first announced on the Google Open Source blog in June 2009. The project saw the light of the day primarily through the efforts of Damon Kohler and it has grown through the contributions of other developers.

It supports most popular scripting languages. These include −

  • Beanshell 2.0b4
  • JRuby 1.4
  • Lua 5.1.4
  • Perl 5.10.1
  • PHP 5.3.3
  • Python
  • Rhino 1.7R2
  • Javascript
  • TCL

Why SL4A – Scripting Languages Vs JAVA

One of the first questions one would probably ask is, “Why use SL4A instead of Java?

Firstly, not everyone is a fan of Java. Scripting languages provide an easy programming environment as compared to Java.

Secondly, the language requires the use of an edit/compile/run design loop. This means that you edit, re-compile and then run the application each time you desire some modification. On the contrary, scripts are interpreted and executed on the fly. Moreover, SL4A even makes it possible, in many cases, to reuse code written for a desktop environment.

The following figure illustrates scripts written in Python targeting SL4A and in Java respectively.

Python Targeting SL4A
Kickstart Your Career

Get certified by completing the course

Get Started