Expose Android APIs to the script engine. This is the critical part – you must define a Java object that the script can call.
// In your activity LuaValue globals = JsePlatform.standardGlobals(); ScriptAPI api = new ScriptAPI(this); globals.set("android", CoerceJavaToLua.coerce(api));
Lua via LuaJIT. It’s tiny (~200KB), fast, and easy to sandbox. Step 2: Set Up the Android Project Create a normal Android project in Android Studio. Add the interpreter as a dependency. scriptable apk
Introduction: Beyond Static Apps For years, Android applications (APKs) have followed a rigid model: a developer writes Java or Kotlin code, compiles resources, signs the package, and distributes it. The end user installs the app and interacts with it exactly as the developer intended—no modifications, no runtime logic changes, and certainly no scripting.
public void showToast(String message) Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); Expose Android APIs to the script engine
Now in your Lua script (loaded from assets or /sdcard/script.lua ):
public int add(int a, int b) return a + b; It’s tiny (~200KB), fast, and easy to sandbox
public class ScriptAPI private Context context; public ScriptAPI(Context ctx) context = ctx;