Android是基于Linux 2.6 内核的系统,所以理论上Linux OS可以运行的脚本语言,给予相应的运行库,在Android也可以运行。
在Android手机上编写并运行Lua脚本
利用开源项目SL4A ( Scripting Layer for Android 项目地址:http://code.google.com/p/android-scripting/ ) ,可以快速在Android手机上搭建各种脚本运行环境。目前SL4A支持 Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, shell 等脚本语言 。
1、下载并安装SL4A运行环境
最新 sl4a_r6.apk 下载地址:http://android-scripting.googlecode.com/files/sl4a_r6.apk
这个应用提供了各种脚本的运行环境,通过拆APK可以看到应用内嵌了两个.so动态链接库。其中一个是ConnectBot的库,另一个是7.9K大小的脚本执行库,但显然不是脚本语言解析库。具体关于SL4A的原理,可以参考博文:《SL4A 之实现原理解析》
2、下载 Lua for android 支持
lua_for_android_r1.apk 下载地址:http://android-scripting.googlecode.com/files/lua_for_android_r1.apk
3、运行Lua for android ,它将从网络下载一些Lua脚本Demo。这些例子在SL4A中运行。
使用SL4A可以在Android手机上直接运行Lua等脚本。
其它脚本语言,可以到 http://code.google.com/p/android-scripting/downloads/list 下载相应的APK。
在Android项目中使用Lua脚本
推荐阅读:
Lua 语言 15 分钟快速入门 http://www.linuxidc.com/Linux/2013-06/86582.htm
Lua程序设计(第2版)中文 PDF http://www.linuxidc.com/Linux/2013-03/81833.htm
Lua程序设计(第二版)阅读笔记 http://www.linuxidc.com/Linux/2013-03/81834.htm
NetBSD 将支持用 Lua 脚本开发内核组件 http://www.linuxidc.com/Linux/2013-02/79527.htm
CentOS 编译安装 Lua LuaSocket http://www.linuxidc.com/Linux/2011-08/41105.htm
http://www.linuxidc.com/Linux/2014-02/96454.htm