Archive for October, 2011

SL4A for Android SDK

                    Some years back Application development for Android was restricted to only Java lovers. Thanks to SL4A (Scripting Layer For Android) ,Scripting languages like Python , Perl  were introduced to Android Application Environment increasing the population of developers considerably. It attracts the developer by allowing them to edit and execute scripts on the Android device. Furthermore scripts can run interactively in a terminal or in background . These scripts have access to many of API‘s available to full-fledged Android Applications. Presently Scripting languages like Python , Perl , JRuby , Lua , BeanShell ,Javascript ,Tcl and Shell are supported on the SL4A.

Python On Android SDK 

      Following steps will lead to the installation of python interpreter on Android SDK.

Step 1: Add the path of tools directory to the environment

         Add the path of the directory  ‘andoid-sdk/tools’ to the path variable by executing the command


                              $PATH =  $PATH:path_of_android-sdk/tools/                       

Step 2:  Create a SDCARD for storing application on Android.

          As Andoid API  2,.2 allows the user to save applications in sdcard insted of using the phone’s memory .So for that purpose a SDCARD of apprpriate size has to be created by executing the command

                              mksdcard    ‘size’M   ‘ sdcardname’ 

This creates a sdcard of  size of ‘size’ MB  with name as  ‘sdcardname’ .


Step 3:  Download the package from the following link

Step 4:  Start the Android SDK and install the SL4A

   Open the terminal and Start the Android-SDK by executing a command like

                              emulator @’avd-name’  -sdcard   ‘sdcardname’

     now  without closing this start a NEW terminal  and  install the sl4a package downloaded earlier by executing the command .

                             adb install  ‘sl4a_rx.apk’

now the icon for sl4a can be seen in the menu of SDK .



Step 5: Installing python from SL4A. 

Now the python interpreter is to be selected in Sl4A . After clicking on the SL4A icon , click on the menu button on the SDK and then click on ‘View’ button  on screen .

then among the list displayed under the ‘View’ button click on the ‘Interpreter’

then among the list of Interpreter’s select Python.

                                              it will download python interpreter and install it.

finally the interactive python shell can be seen on the ‘Android SDK’.

This was helpful to me as my major project was to develop a Scheme to Python compiler for Android Simulator. So for that purpose it was necessary to get an environment setup where python code can be run for Android OS.