Deploying AIR apps to

Amazon and NOOK with Flash CS5.5

Through my good friend Google and my other friend Trial and Error, I’ve finally got Deco Sketch in line for review at the last 2 remaining worth-while app stores. I’m still debating if BlackBerry is worth it considering the small user base. I haven’t written it off yet, I just need to put it down for now and focus on client projects right now.

Deploying to Amazon is nearly identical to Android. You can use the same .apk file published from Flash Professional CS5.5 for use on Android with one exception. The AIR download URL needs to be updated for users without it already installed, or it needs to packaged with the captive runtime. I’ll show you both ways so you’re not stumbling around the web sorting through endless dead-end links like I was.

The easier approach is updating the AIR download URL for Amazon. While you can select which market your app is being deployed to in the AIR publish settings, the actual link it points to is wrong. Why Adobe hasn’t issued an update for Flash Professional CS5.5 is beyond me. You’ll need to find the market.xml file in your Flash application folder usually located at C:\Program Files\Adobe\Adobe Flash CS5.5\en_US\Configuration\Android  on Windows. The URL for Amazon is set to

"http://www.amazon.com/gp/mas/dl/android/com.adobe.air"

but it needs to be:

"http://www.amazon.com/gp/mas/dl/android?p=com.adobe.air".

A minor difference but a difference nonetheless. Publish as you would from the Flash IDE and your .apk now points to the correct location to download AIR if the user doesn’t already have it installed.

The other way is to package your app with the AIR captive runtime using the ADT ( AIR Development Tool ). The advantage here is you have control of what version is being used and the user isn’t asked to download another app. In the case of the NOOK this is handy considering it only supports AIR 2.6 and can’t be user upgraded. The disadvantage is that it ads approximately 8mb to your app.

ADT is included with the Adobe AIR SDK which you can be downloaded here: http://www.adobe.com/special/products/air/sdk/. You may already have in installed with Adobe Flash Pro CS5.5 in this directory: C:\Program Files\Adobe\Adobe Flash CS5.5\AIR2.6\bin file name adt.bat. If you need to download the SDK, I recommend extracting the files somewhere that’s easy to get to. The root of your OS drive is convenient: c:\AIR. Currently, AIR is at version 3.1. If you need to overlay Flash Pro with 3.1, follow the instructions here: http://kb2.adobe.com/cps/908/cpsid_90810.html

Once ADT is downloaded, you’ll need to pull together all the files your app needs to compile – myApp.apk, myApp.swf, myCert.p12, myApp-app.xml, icon36.png, icon48.png, icon72.png and any other files your app relies on for publishing. In the essence of making things simple, I recommend copying these files to the same folder that adt.bat lives ( in the \AIR\bin directory of the AIR SDK ), temporarily. This way, the command is shorter, easier to read and less prone to error. You can just delete them or put them back in your apps project directory afterwards.

If you’re not comfortable working with the command line, this is where it gets a little tricky. In Windows, Start > Run > cmd.exe. On mac, Applications > Utilities > Terminal. Navigate to the ADT ( adt.bat ) location using the change directory command:

cd c:\AIR\bin\

If you put AIR on another drive than your OS:

cd/d i:\AIR\bin\

Now you need to put together a long command string that references the app resource files that looks something like this:

adt.bat -package -target apk-captive-runtime -storetype pkcs12 -keystore myCert.p12 myApp.apk myApp-app.xml myApp.swf icon-36_android.png icon-48_android.png icon-72_android.png

Pay close attention to the “-” locations. These specify the commands to be executed. I found it was easiest to type this out in a text file first rather than directly in the command line. You can then copy and paste.

A note about the icons: be sure they’re in the same relative location as specified in the AIR publish settings in the Flash Pro IDE. By default, Flash creates an “AppIconsForPublish” directory within your bin folder and copies the icons there. If you haven’t changed the myApp-app.xml file, then this is where your app expects them to be. Also, if you’re using the same source FLA for iOS deployment, the myApp-app.xml file will likely have references to the iOS specific icons as well. Delete those entries from the xml for now ( Flash will put them back next time you open the publish settings ) otherwise ADT will give you an error stating that they’re missing and won’t compile. So your final XML file should only reference Android icons:

<icon>
    <image72x72>AppIconsForPublish/icon-72_android.png</image72x72>
    <image48x48>AppIconsForPublish/icon-48_android.png</image48x48>
    <image36x36>AppIconsForPublish/icon-36_android.png</image36x36>
</icon>

If all your i’s are dotted and t’s are crossed, you’re ready to compile your .apk file with the command line you created. Copy and paste your formatted ADT command into the terminal and hit enter, if everything’s where it should be, you should get a 2-3 pause and then asked for your password.  Enter your password ( it doesn’t show what you type in so be sure to do it only once ), hit enter, and voila! You’ve got your self an Android app ready for deployment with the AIR captive runtime included! You should see your new compiled .apk file updated in filesize + about 8mb. If you get an error, retrace your steps, double check your command string and try it again.

If you’re compiling for the NOOK, you’ll only need to use ADT if you’re app is published with AIR 2.7 or higher. The NOOK only supports AIR 2.6 right now. Flash Professional CS5.5 comes pre-installed with AIR 2.6 so if you haven’t updated it, you can publish direct from the IDE without the need for any of these steps.

I spent a bunch of time online trying to track this info down. Wojciech Sierakowski’s article on AIR for Android and iOS was a great help.

Leave a Reply