Monday, December 8, 2008

Debugging Tips for Air Applications in Flex

When you run (or debug) either your own or other people provided Air applications, sometimes it won't start even you click the Run (or Debug) icon in FlexBuilder. Here lists three scenarios and their possible solutions in the following table:


Possible Cause

Possible Solution

Wrong AIR runtime version specified in the xmlns attribute of application property in the application descriptor file.

Change
<application xmlns="http://ns.adobe.com/air/application/1.1">

to
<application xmlns="http://ns.adobe.com/air/application/1.0">

if you're running AIR 1.0 runtime instead of 1.1.

This could happen when you're running other people provided application and your Flex Builder version is different from his/hers or you've updated your Flex Builder to a newer version.


The error message should be "Invalid application descriptor: descriptor does not match runtime version." or "error while loading initial content" when you debug it.

A zombie adl.exe prevents AIR application from running.

Bring up Task Manager and if there is a zombie process called adl.exe (i.e., AIR Debug Launcher), kill it. This can be helpful if Flex complains that it cannot connect to the debug process.
Sometimes, you also need to restart FlexBuilder to fix it.
Caching Problem Go to your application descriptor file and bump up your version number. I found out that this can be helpful sometimes.


If the above solutions don't apply to your own situation, the last resort is to examine Eclipse Error Log file (i.e., ".log"). This file stores messages from the Eclipse environment. The default location of this log file on Windows XP is c:\Documents and Settings\user_name\workspace\.metadata\.log.

For MacOS and Linux, the default location is also in the workspace directory, but files and directories that begin with a dot are hidden by default. As a result, you must make those files visible before you can view the log file.

One of the possible causes described above is related to the incompatible tech stack versions. Therefore, it's essential for you to know what compile/linkage/runtime environment your AIR application is compiled/linked/run against. To figure out these version information, here we list where or how to find them:


Version Information

Where to Find

Flex Builder

Read from "Add or Remove Programs" or "About Adobe Flex Player..."

Adobe AIR runtime

Read from "Add or Remove Programs."
Adobe Flash Player ActiveX

Read from "Add or Remove Programs."
Required AIR runtime version for AIR application to run

Read the xmlns attribute of application property in the application descriptor file.

Minimum player version that will run the compiled AIR application Read the target-player value from global Flex configuration file air-config.xml. The default location of this log file on Windows XP is C:\Program Files\Adobe\Flex Builder 3\sdks\3.1.0\frameworks\.
Which SDK to link with for the AIR application

Read default Flex SDK from Installed Flex SDKs (i.e., Window > Preferences > Flex > Installed Flex SDKs).

Note that it's possible to target different Flash players (i.e., either Player 9 or Player 10) with the same SDK.  See Targeting Flash Player 10  for  details.



After you resolve all setup issues, you should be able to run debugger. AIR supports debugging directly, so you do not need a debug version of the runtime (as you would with Adobe® Flash® Player). To conduct debugging in Flex, see Debugging Flex Applications authored by Mike Morearty.

No comments: