Wednesday, November 03, 2010

AIR for Android Tutorial

I've been developing a few AIR applications using AIR 2.5 and packaging them up as *.apk's for Android O/S.  The steps are relatively easy. You must have the following items to complete this tutorial:
  1. An unlocked and tethered Google Android device with Android 2.2 or later installed;
  2. Flash Builder 4.1;
  3. The Adobe AIR 2.5 SDK;
  4. The Google Android SDK;
First you need to get Flash Builder 4.1 and overlay the AIR 2.5 SDK.  Copy the AIR 2.5 from the Adobe Labs site to your desktop.

Copy the AIR SDK to the directory where you installed Flash Builder /sdks/.
Before unpackaging the AIR SDK to that directory, make a copy of the sdk you will overlay the AIR SDK on to.
With a terminal window, navigate to the directory /sdks/ and type:


       tar -jxvf AIR25_mac_sdk_XXXXXX.tbz2


This should unpackage the *.tar file and overlay your SDK. 


2. Building your AIR application

1.     Start a new project in Flash Builder with the following parameters:

Application Type: AIR
SDK: 4.1 (use the SDK you wrote AIR 2.5 into above)

2.     Change the root element from <s:WindowedApplication> to <s:Application>.

3.     Open the application descriptor file and navigate to lines 154 and175. Uncomment the entire android manifest section.


4.     Navigate to line 96 and uncomment, make “mobileDevice”.

5.     Save the descriptor and close it.

3. Packaging and putting your app onto your device

1.     Open a terminal and navigate to
             /AIR25_mac_sdk_20100930/bin

         For example:


              
     cd /Users/duane/Desktop/Android/AIR25_mac_sdk_20100930/bin

2.     Using finder, copy the SWF and the app descriptor from the Flash Builder /bin-debug folder of your workspace over to the SDK.  (N.B. SDK must be the same version!)

3.     In the terminal, type in the following.  You will need a PKCS12 certificate set up to do this and modify the path to point at your certificate.  The next parameter is the name of the output *.apk (in this example "Android-REST.apk") following by parameters of the XML descriptor and the main swf file.

./adt -package -target apk -storetype pkcs12 -keystore ../../certificates/Sharkswithlaserbeamsinc.p12 Android-REST.apk ./Main-app.xml ./Main.swf


4.     In your terminal, CD to /android-sdk-mac_86/tools.  Test the device connection by running the ADB devices command:

./adb devices

5. Install your application by typing ./adb install -r ../../AIR25_mac_sdk_20100930/bin/Main.apk
Substitute the path to the newly created *.apk.
Launch the app on Android.  It should run as any other app but the name of the original *.mxml file will be the name of the app.

No comments:

Post a Comment

Do not spam this blog! Google and Yahoo DO NOT follow comment links for SEO. If you post an unrelated link advertising a company or service, you will be reported immediately for spam and your link deleted within 30 minutes. If you want to sponsor a post, please let us know by reaching out to duane dot nickull at gmail dot com.