Packaging a mobile AIR application for Android

AIR applications on Android use the Android application package format (APK) rather than the AIR package format. You can use the AIR Developer Tool (ADT) tool to create an APK package for your AIR application.

Before you can package an AIR application for Android, you must set up the Android SDK. See Android setup.

Packages produced by ADT are in a format that can be submitted to the Android Market. The Android Market does have requirements that submitted apps must meet o be accepted. You should review the latest requirements before creating your final package. See Android Developers: Publishing on the Market.

Developer Serge Jespers has created Package Assistant Pro, an AIR application that assists you in packaging AIR apps for Android. You can download the application at http://www.webkitchen.be/package-assistant-pro/.

Packaging with ADT

You can use the AIR ADT command-line tool to package an AIR for Android application. The AIR SDK version 2.5 supports packaging for Android. Before packaging, all your ActionScript, MXML, and any extension code must be compiled. You must also have a code signing certificate. You can use a normal AIR code signing certificate; however, to submit an app to the Android Market, the certificate must conform to the Market rules, which require the certificate to be valid until at least 2033. You can create such a certificate using the ADT -certificate command.

For a detailed reference on ADT commands and options see AIR Developer Tool (ADT).

Creating an APK package

To create an APK package, use the ADT package command, setting the target type to apk for release builds, apk-debug for debug builds, or apk-emulator for release-mode builds for running on an emulator.

adt -package -target apk -storetype pkcs12 -keystore ../codesign.p12 myApp.apk myApp-app.xml myApp.swf icons

The example assumes that the path to the ADT tool is on your command-line shell’s path definition. (See Path environment variables for help.)

You must run the command from the directory containing the application files. The application files in the example are myApp-app.xml (the application descriptor file), myApp.swf, and an icons directory.

When you run the command as shown, ADT will prompt you for the keystore password. (The password characters you type are not displayed; just press Enter when you are done typing.)

Creating a debug APK package

To create a version of the app that you can use with a debugger, use apk-debug as the target and specify connection options:

adt -package -target apk-debug -connect 192.168.43.45 -storetype pkcs12 -keystore ../codesign.p12 myApp.apk myApp-app.xml myApp.swf icons

The -connect flag tells the AIR runtime on the device where to connect to a remote debugger. For most debugging features to work, you must also compile the application SWFs and SWCs with debugging enabled. See Remote debugging connection options for a full description of the -connect flag.

On Android, the app must also have permission to access the Internet in order for it to connect to the computer running the debugger. See Android permissions.

Creating an APK package from an AIR or AIRI file

You can create an APK package directly from an existing AIR or AIRI file:

adt -target apk -storetype pkcs12 -keystore ../codesign.p12 myApp.apk myApp.air

The AIR file must use the AIR 2.5 namespace in the application descriptor file.