« Flex 4 Skins are Awesome! | Main | Congrats to Open Flex! »
AIR Update Framework
| By Rich Tretola | August 1, 2008 | |
| 8,837 views |
I have been using the new AIR Update Framework in all of my new AIR applications in place of my UpdateManager that was originally written to handle application updates before the Adobe version was released.
The simplest way integrate this framework into your application is to setup your local configuration file with the checkForUpdate property set to false and all others set to true. This property is not telling the framework to never check for updates, it is simply telling the framework to hide the check for update dialog from the user so they will only see a dialog if an update actually exists.
In the sample below notice that the only other property that is necessary is the address of the remote update file. This local configuration file will ship with your application.
1 2 3 4 5 6 7 8 9 10 11 | <?xml version="1.0" encoding="utf-8"?> <configuration xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0" > <url>http://www.mydomain.com/AIR/Test/update.xml</url> <delay>1</delay> <defaultUI> <dialog name="checkForUpdate" visible="false" /> <dialog name="downloadUpdate" visible="true" /> <dialog name="downloadProgress" visible="true" /> <dialog name="installUpdate" visible="true" /> </defaultUI> </configuration> |
The remote file contains only a few properties. Notice the sample below where I have set a version property, url to the newest application file, and a small description which will display in the release notes section of the updater dialog.
1 2 3 4 5 6 7 8 9 10 11 12 | <?xml version="1.0" encoding="utf-8"?> <update xmlns="http://ns.adobe.com/air/framework/update/description/1.0"> <version>.2</version> <url> http://www.mydomain.com/AIR/Test/myApp.air </url> <description> <![CDATA[ Added new image rotation feature. ]]> </description> </update> |
Finally, within the application do the following:
Create an instance of the updater on line 8
After the application completes, I set the path to the local configuration file within the init function.
Next, I add an eventListener to listen for when the updater is initialized.
Within the eventListener function, I then call the checkNow() function.
Since, we hid the first dialog, the updater will now check for the update and only show the user a dialog when an update exists (see image below). If so, it will then walk them through the rest of the update process.
Here is the full application code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()"> <mx:Script> <![CDATA[ import air.update.events.UpdateEvent; import air.update.ApplicationUpdaterUI; private var updater:ApplicationUpdaterUI = new ApplicationUpdaterUI(); private function init():void{ updater.configurationFile = new File("app:/config/updaterConfig.xml"); updater.addEventListener(UpdateEvent.INITIALIZED, updaterInitialized); updater.initialize(); } private function updaterInitialized(event:UpdateEvent):void{ updater.checkNow(); } ]]> </mx:Script> </mx:WindowedApplication> |

Topics: Adobe AIR | 30 Comments »








August 4th, 2008 at 9:57 am
I have implemented the AIR Updater in my First AIR application. When the version changes the Updater show its messagebox correctly but I receive the following message:
There was an error downloading the update. Error# 16820
I am sure that the remote update.xml and the application-app.xml have the same new version number
Can you help me !!!
Reply to this comment
August 4th, 2008 at 11:27 am
Did you check to make sure the path to your new AIR file set within the url property of the remote update.xml file is accurate?
Reply to this comment
August 5th, 2008 at 7:27 pm
Yes it it. Both the update.xml and the application-app.xml have tha same new version and the URL is OK.
The message box appears to download the new version so it is looking in the right place.
Reply to this comment
Dilip Shah Reply:
December 19th, 2008 at 5:15 pm
Hi Marcus,
Did you manage to resolve this issue? I’m running into this issues on my local machine.
Reply to this comment
August 5th, 2008 at 8:07 pm
So, it downloads but can’t update?
Reply to this comment
August 25th, 2008 at 7:24 pm
Yes, we tried this as well …
Seems to be a bug …
Any fixes ?
Regards,
Sean.
Free Digital Signage powered by Adobe AIR
http://www.MediaSignage.com
Reply to this comment
Rich Tretola Reply:
August 25th, 2008 at 7:54 pm
I have not been able to reproduce this issue.
Reply to this comment
August 29th, 2008 at 12:17 pm
I have run into the same issue. Versions are the same URL is fine. Also it works fine when run on my localhost but once I change the URL’s to my live website it throws the error…”There was an error downloading the update. Error# 16820″. It detects the correct version to be updated, the correct AIR file is in the correct directory.
I am wondering seeing as this only happens when I publish it live if it has something to do with my hosting company. I use Host My Site.com and they are usually up on things. I tried changing file permissions on the folder containing the app but that did not work either. I have a feeling it might have something to do with it being on a shared hosting server.
Anyone have any thought or suggestions?
Reply to this comment
Chris Reply:
August 29th, 2008 at 12:24 pm
BTW… When my app checks for the update it sees the “Installed Version” and the “Update Version” in the “Update Available” window, but never downloads the app like Sean is describing above. As soon as I click on the “Download Now” button it throws the “Download Failed” error message.
Reply to this comment
September 3rd, 2008 at 8:52 am
I think the application ID has to be the same, and also the certificate.
Reply to this comment
September 16th, 2008 at 5:02 am
2Chris: Make sure, that inside “update.xml” you point to correct download path of your AIR application.
I’ve also had received Error# 16820 before, because the download path of AIR application inside “update.xml” file was incorrect.
Reply to this comment
Pedro Reply:
November 5th, 2009 at 4:14 pm
It work in my case.
Reply to this comment
January 14th, 2009 at 5:16 am
People can you say me if it possible to update non air application. We use an exe program which run adl.exe and indicates needed path. How to do the update of swf. Is it possible with this library?
Reply to this comment
January 20th, 2009 at 12:20 pm
For others like me who were having a hard time making this function correctly. You need to add the following to the top of your update.xml in addition to what Rich has specified above. I was recieving an Error: 16815 before I added the encoding and xmlns.
Reply to this comment
January 22nd, 2009 at 9:06 pm
Hi. do you know some way to make that the dialog box could be in other language
waiting for you response
thx
Reply to this comment
Rich Tretola Reply:
January 22nd, 2009 at 11:41 pm
Check the section titled “Defining the update descriptor file and adding the AIR file to your web server” at http://help.adobe.com/en_US/AIR/1.5/devappsflash/WS5b3ccc516d4fbf351e63e3d118666ade46-7ff2.html
Reply to this comment
February 6th, 2009 at 4:02 pm
I am having a terrible time with this. Currently about 98% of the time i get [DownloadErrorEvent (type=downloadError text=Error #3013: File or directory is in use. id=16818 subErrorID=3013)]. Sometimes i can get it to work in the IDE after doing a project clean.
Is there anywhere to go for paid support with this, or do i really have to resort to writing my own. I thought this was out of beta in AIR 1.5?
It would really be nice to be able to tell which file or directory is in use so i can watch it or otherwise figure out why.
Reply to this comment
February 28th, 2009 at 6:09 pm
There is an extra ‘<
Jon
Reply to this comment
March 6th, 2009 at 8:33 am
I’m running into the same issues as others here. I’ve blogged about my troubles:
http://www.andymatthews.net/read/2009/03/05/AIR-Updater-class-is-giving-me-trouble.-Can-you-help?
Part of the problem is that Adobe docs on this issue are not worth much, the other problem is, like everyone else here, my version and URL verify just fine. I get the update box, it sees the local, and remote, versions but throws an error when trying to download the file. I’ve gotten errors 16815, and 16824.
Reply to this comment
June 7th, 2009 at 4:32 pm
I used this update, but I have one problem
When I update the application, all my data on the database is lost.
Any help?
I check is the database exist:
sqlFile = File.applicationDirectory.resolvePath(”archive.db”);
if(!sqlFile.exists){
sqlConn.open(sqlFile, SQLMode.CREATE);
createDatabaseDB();
}else{
sqlConn.open(sqlFile, SQLMode.UPDATE);
}
Thanks
Reply to this comment
September 25th, 2009 at 11:27 pm
I received the 16820 error, and it was my fault — the folder I pointed to had a password (read protected), so I guess AIR failed silently. When I corrected this, I then got another error (like 18xx or something), and that was a problem with my XML file on the server — I found that out by Googling the error number.
Now it all works okay except when I try to install the download while the app is still running, the installer tells me that the AIR file is damaged. However, when I say “download but install later”, and then I close and re-open the application, AIR starts the update but then gets stuck during “telling the app to exit”. If I manually close the app at this time, the update succeeds.
It sounds like my exit routine that AIR is trying to call is not functioning properly. Does anyone know what the installer is trying to call to exit the app?
Reply to this comment
November 17th, 2009 at 11:43 am
[...] For more information on updating AIR applications, please see this post. [...]
November 25th, 2009 at 11:18 am
Have you guys added the .air mime type to your servers?
Reply to this comment
January 1st, 2010 at 11:50 am
I had created an application adobe air 2. When i tried to implement update feature to my application using ApplicationUpdaterUI
i am getting following error message and not been able to implement update feature to my application
VerifyError: Error #1053: Illegal override of callInContext in _ApplicationUpdaterDialogs_mx_managers_SystemManager.
please help me.
Reply to this comment
john.liao Reply:
January 18th, 2010 at 1:15 am
I think you should use applicationupdater_ui.swc but not applicationupdater_ui4.swc. I have the same problem as you, and have resolved it after remove the lib applicationupdater_ui4.swc from my project library path.
Reply to this comment
February 18th, 2010 at 7:37 am
Hi Guys,
I have a flex air application which I build it in my desktop and port it to the clients with a CD/DVD.
I have tried building a sample air application and with two versions with true in my application XML file.
With this when I install version1 it gets installed normally.
When the user wants to update his version to version2 he has to manually copy the air file to the desktop from the CD.Since I have been using below code:
public function updateVersion(updatedVersionName:String,updatedVersionAir:String):void{
var updater:Updater = new Updater();
var airFile:File = File.desktopDirectory.resolvePath(updatedVersionAir);
var version:String = updatedVersionName;
updater.update(airFile, version);
}
When he runs the air file from the desktop it first opens the version1 UI and there he has to click the update link there which calls the above function to update his version.
Is there no other better way to manage this scenario.All the examples I see in the internet are downloading from remote server but my case is that the client doesn’t have internet access.
Thanks in advance.
pappu.
Reply to this comment
Rich Tretola Reply:
February 18th, 2010 at 10:25 am
The update framework is meant to be an Internet based service. You can certainly use a local server but it would still need to be over http.
Reply to this comment
Pappu Reply:
February 18th, 2010 at 1:13 pm
Thanks for the update Rich.
I figured out another way to solve this issue.Since I am sending a CD to the client place I am planning to package the swf file and xml in a exe and replace them in in the program files where I first install the version#1.
Not sure if this works,still in the process of exploring this option.
Reply to this comment
Rich Tretola Reply:
February 19th, 2010 at 9:23 am
You can also use AIR 2.0 to package to .exe. Please see http://blog.everythingflex.com/2009/11/17/your-first-air-2-0-exe-file/ and http://blog.everythingflex.com/2009/12/15/adobe-air-passing-arguments-into-native-executables/ for examples of this.
February 19th, 2010 at 9:27 am
Thanks for the update Rich I’ll try this option also.
Reply to this comment