Updating Adobe Flex Applications to AIR 2.6

July 27, 2011
- Jan

I recently had the pleasure of trying to force Adobes braindead AIR framework to update a Flex application to a new version that was using Flex 4.5 instead of 4.1. This was a major pain in the ass. Here I want to describe the steps I took to finally make it work.

Flex 4.1 Apps that use Air require Air 2.0 as a minimum, Flex 4.5 Apps require Air 2.6.

The Air Updater Framework

In the application descriptors above you see that the version tag has changed to versionNumber. This change was introduced in Air 2.5. At the same time, Adobe introduced a similar change to the update descriptors. These are two versions of the same Air update, once for Air < 2.5, once for Air >= 2.5:

The solution (theory)

Create an intermediary version that is built with Air < 2.5, but compile it with the Application Updater libraries from Air >= 2.5

Distribute that version to your clients using a Air 2.0 update.xml

Create the new version with Air >= 2.5

Distribute the new version using a Air 2.0 update.xml

From then on you should use the 2.5 namespace for the update.xml

Step 4 is crucial:

Although the intermediary version was built with the new update framework that can process the 2.5 update.xml, doing so will result in an error.

Air will complain that the update descriptor namespace must match the application descriptor namespace (of the currently running application, not the one you just downloaded).

Now, all this is quite frustrating but it sounds pretty clear to implement, until you actually start with step 1.

The solution (practice)

This isn’t actually all that hard with Flash Builder:

Go to “Project Properties”, “Build Path”, unfold the Flex Framework in the list and remove applicationupdater.swc and applcationupdater_ui.swc. Then click “Add SWC” and add those two files from your Flex 4.5 framework location (/Applications/Adobe Flash Builder 4.5/sdks/4.5.0/frameworks/libs/air/applicationupdater.swc on Mac).

The catch? All but the most trivial of applications will use the commandline compiler in a custom build script or the mxmlc task in an Ant buildfile. How do you perform the equivalent of what we just did in Flash Builder in those cases?

This crap took me half a day to figure out. I’m giving you the Ant version:

The first library-path is append="false" and thus clears out any existing library paths that have been set through the frameworks default flex-config.xml and air-config.xml. Inside that block, I include the default flex libraries.

Next, I include the new updater framework.

In the third step, I include the other Air-related files as they would have been by the air-config.xml file. Because the updater framework 2.5 has already been loaded, this line will not include the 2.0 updater.

Finally, I add my custom libraries.

The equivalent solution for the mxmlc commandline compiler should be (not tested):