If you own an Android 2.2 (Froyo) device you must know that you can already start building (and testing!) your AIR 2.5 applications for Android. There’s more: if you are an FDT user like me you should be glad to know that is very easy to build and package our AIR4Android applications without even leaving our favorite tool!
I’m not going deep into how to setup your Eclipse environment with FDT as I assume you already have some sort of confidence with both of them. Let’s say you have a working copy of Eclipse and just installed FDT professional (or whatever version you like). Once you have these programs installed we can take care of SDKs.
Go to Android developer portal and download & install latest Android SDK for your platform. You can simply follow default installation instructions for this. In the same way download Flex 4.1 SDK and extract all content in a specific folder of your hard disk. At this point you just need to merge Flex SDK with AIR 2.5 SDK. The AIR 2.5 download is restricted to the Android Prerelease program members, you can sign up here. Finally configure FDT’s preferences to use the new Flex SDK location.
Please, refer to the official documentation to know how to setup your Android virtual devices and emulator if you want to debug your applications on the SDK emulator first… We will focus just on compiling the apk (Android installable) file we need to test the application on a real device.
The project will be a simple, standard AIR project. The basic structure includes the app-xml descriptor, the main class file and icons we need for our application. Be sure to change your application descriptor namespace to include “2.5″:
and the “initialWindow” visible flag is set to true:
Now we have our project ready to be compiled and packaged. This should be the most boring part but I was able to quickly adapt a great ANT file shared from Jonathan Campos in a recent post.
Basically it consist in a total of three files; base.properties, build.properties and build.xml. The first two are just storing all path variables we’ll need to compile (SDKs, source files, assets location etc…), while build.xml takes care of compiling the swf, create a proper certificate, package the apk file for us and install on device too!
You just need to change build.properties to fit your setup:
[cce]# Flex SDK File Location on your computer
#Android SDK Folder on your computer
That’s all! You can either run ANT file from command line of from Eclipse. Below you can see a picture showing how your project should look like:
Download and test!
I know, it’s a little boring to set up all this stuff before actually starting coding the good things. To solve this problem I uploaded a template project on google code for you to check out and use as base code for your next AIR Android killer app, enjoy:
Feel free to send me your comments and suggestions!
http://developer.android.com/sdk/index.html (Android SDK)
http://labs.adobe.com/technologies/air2/android/ (Android prerelease program
http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4 (Flex 4.1 SDK)
http://unitedmindset.com/jonbcampos/2010/07/19/android-mobile-development/ (Original ant file)