[SOLVED] Generate a Stack Trace in an Flex/AIR Release Build

This has been a source of frustration for such a long time, I had to share the solution. Credit for this one goes to Martin McBrearty, and there are a few other blogs out there that support this method.

Important Disclaimer: This method does not appear to be officially supported, and is not guaranteed by me or anyone else to work. Use at your own risk!

Flash Builder is a great tool, and offers wonderful debug support. However, once an application has been deployed in the field, it would be nice to be able to troubleshoot any bugs that might arise. Sadly, Adobe AIR offers poor support for exception handling. The biggest issue is that an exception caught in a release build of an app generates no stack trace. This means you get a very general error (i.e. cannot access properties of a null object) but no other helpful information.

This has proven to be a significant stumbling block for Flex/AIR. Other technologies allow for robust exception reporting, helping developers identify issues that otherwise couldn't be diagnosed. Lucky for us, there is a workaround, and it is forehead-slappingly simple.

For Windows machines, after installing the release build of your application, browse to its install directory in a file explorer. Navigate down a few levels to {app-folder}\META-INF\AIR\. Here you will want to create an empty file called "debug", with no file extension. In versions of Windows with annoying user account control settings, you may have to create the file elsewhere and move it to where it belongs.

And that's it!

Fire up your application and cause an exception. Inside the try/catch block, you'll have access to a full stack trace, just as you would if running in debug mode. Use that information to log exceptions, report info to the user, send yourself an email - whatever suits your application best.

Big thanks again to Martin McBrearty for this one. Happy coding!

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.002. Contact Blog Owner