As of mid-2008, Hecl runs on Google's Android platform, although it's not yet a 'mature' port. That's ok right now, though, because Android isn't production ready yet, either.
Due to a different GUI model, a very extensive API, and a much more complete implementation of Java [1] Hecl on Android takes a different approach: the Android version of Hecl includes a java command, and introspection capabilities in order to be able to dynamically create Hecl commands that call out to native Java calls.
Developing for Android Hecl is quite similar to Java ME development, with the same cycle of editing a script, creating an application bundle, and testing it in an emulator.
To work with Android, of course the first thing you need to do is to get the SDK from
Google: http://code.google.com/android/download.html. On my system, I
installed it in here: /opt/android-sdk_m5-rc15_linux-x86/
. Next,
edit android/android.properties
to point to the SDK, and the tools
it needs to work (usually the tools
directory within the SDK
directory).
As with Java ME Hecl, you need a script file to work with. Here's a "hello world":
set layout [linearlayout -new $context] $layout setorientation VERTICAL set layoutparams [linearlayoutparams -new {FILL_PARENT WRAP_CONTENT}] set tv [textview -new $context -text {Hello World} -layoutparams $layoutparams] $layout addview $tv [activity] setcontentview $layout
To see more code, have a look at android/res/raw/script.hcl
, which
has examples of many different widgets.
You won't need it right away, but you might as well start the emulator:
/opt/android-sdk_m5-rc15_linux-x86/tools/emulator &
Now we create the new Hello.apk
file.
java -jar ./hecl/jars/AndroidBuilder.jar -android /opt/android-sdk_m5-rc15_linux-x86/ -class Hello -label Hello -package hello.world -script hello.hcl
The command line options are as follows:
-android : The location of the Android SDK |
-class : The class name to utilize for the new .apk. |
-label : The user-visible name of the package. |
-package : The Java package to use. You can pretty much use any
name you like, it doesn't matter much. |
-script : The location of the script you want to use in the new .apk. |
Once you have successfully created a new Hello.apk
, you can
send it to the emulator:
/opt/android-sdk_m5-rc15_linux-x86/tools/adb install Hello.apk
[1] Android doesn't actually run Java, it just compiles code written in Java into bytecodes for the Dalvik engine.