Mise en place
- Downloaded the Flex 4.5.1 sdk and the AIR 2.7 sdk.
- Read Adobe's article on "Differences Between Flex 3 and Flex 4"
- Looked into the "Adobe Flex 4 Features and Migration Guide" document
- Merged the new sdks into a folder named "Flex 4.5.1 with AIR 2.7" (here's a good reference on "How to Overlay the AIR SDK for Use With the Flex SDK"
- Opened my project in Flash Builder 3 and set the compiler setting to reference the new sdk:
- Under Properties > Flex Compiler > Configure Flex SDKs clicked "Add..."
- Browsed to the "Flex 4.5.1 with AIR 2.7" folder"
- Set the Flex SDK version to the new sdk
A bunch of errors and warnings appeared in the "Problems" view. These will depend on each project and are usually self-explained and easy to solve, so I just leave an example:
"3608: 'application' has been deprecated since 4.0. Please use 'FlexGlobals.topLevelApplication'."
Just replace every "Application.application" reference in your project with "FlexGlobals.topLevelApplication". Remember to also replace the "import mx.core.Application" with "import mx.core.FlexGlobals".
After cleaning up all errors and warnings I tried to debug the application, which brought me to Problem #2.
"Process terminated without establishing connection to debugger. error while loading initial content"
This error basically meant that I had to update the air namespace of my application. To solve it I opened the application's descriptor file (that file that is automatically created with every new application and ends in "...-app.xml", something like "myAppTest-app.xml") and made sure the air namespace matched the one in the sdk:
Now that this was solved, I tried again to debug the app, bringing Problem #3.
invalid application descriptor: versionNumber must have a non-empty value."
This problem was produced by a mismatch in the application's descriptor file. Each AIR sdk tends to have it's own application descriptor file formatting which means that an application that was created with AIR 2.0 must "migrate" its descriptor file to the new AIR 2.7 sdk. My suggestion is creating from scratch a new project that targets the new sdk, just so we can take its descriptor file, copy/paste it to our "old" project and change the necessary values to adapt our project (such as project name, etc).
I later noticed that if I had changed the whole descriptor file to begin with I would have bypassed problem #2...
Finally, after all this, I was able to run my application sucessfully. Up until I tried to create a release build of my application, which brought me to Problem #4.
Because it was a silent error, problem #4 was the most annoying one (I later found that some silent errors can be detected by watching Flash Builder's log file). What happened was that I simply was unable to finish the release build process - I would click the "Finish" button, after all the "create release build" steps, but the popup window just wouldn't close and the ".air" file wouldn't be created.
I found online that some people have had this problem due to having added a space inside some of the tag values in the descriptor file. This was not my problem but I looked into my "...-app.xml" file and found out that I was defining the app's icon image for only 4 of the 6 available sizes (in flex 3 we just needed to define 4 icon images while in flex 4 we must define it in 6 sizes). Apparently you are required to define the icon's image in all sizes.
After commenting the <icon> tag of my descriptor file (I didn't have the time for creating the new required images at the time), I was able to successfully create a release build of my app.
It took me a couple of hours to migrate my project (not counting on migrating all mx components to the new Spark components). Perhaps if I had tried to have a better understanding of the whole migration process beforehand it would have saved me some trouble, but it was a time vs effort decision.
Now let's see if the new sdks were worth it ;)
Here are some more references I found useful: