July 24, 2014
 
 
RSSRSS feed

Android Scripting With Python

Installation and Hello World

  • August 19, 2010
  • By Paul Ferrill

One of the things about the Android platform that appeals to many in the Linux community is the fact that it's based extensively on open source, Oracle lawsuits notwithstanding. The primary way to write applications for an Android-based phone is still Java. Google provides a Software Development Kit (SDK) with all the documentation, libraries and tools you need. There's even an add-on for the open-source Eclipse Integrated Development Environment (IDE) to help you along.

<em>figure 1</em>
figure 1

Google recently released a new and improved version of what was previously called the Android Scripting Edition (ASE) now renamed to Scripting Layer for Android (SL4A). This downloadable application for your phone opens up a whole new world of ways to program your Android using familiar languages like Python, Perl, Jruby and Lua. There's also support for BeanShell, JavaScript, Tcl and standard Linux shell commands. In this article we'll walk you through the process of installing the tools and the basics of scripting your phone.

Installation

The first thing you need to do is download the appropriate SDK for your phone. We used the HTC Evo 4G running the latest version of Android code named Froyo. You can get started with scripting your phone by downloading the SLA4 application using either the Android Market on your phone or by scanning the QR code on the SLA4 website. Once installed you'll have a new icon labeled SLA4 on your application launch screen.

<em>figure 2</em>
figure 2

Touching the SLA4 icon launches the scripting host which initially has only the Shell interpreter installed. You can download other interpreters from the SLA4 homepage. If you happen to have the very cool Firefox add-on to send stuff straight to your phone and the Chrome to Phone app on your phone, you're literally just one click away from sending it to your phone. For our testing purposes, we downloaded the Python interpreter, which puts a 2.6.2 version of the Python language on your phone.

If you really want to get serious about writing and debugging code, you'll need to install the Android SDK. You'll find versions for Linux, Mac OS X and Windows on the Android SDK download page. For Linux, you basically unpack the tgz file and set an environment variable to add the SDK/tools directory to your search path. You'll also need either version 5 or 6 of the Java Development Kit (JDK). They have a page of notes for installing on Ubuntu to help get you up and running. Once that's done, you should be good to go to connect up your phone and start hacking away!


Sitemap | Contact Us