4

I'm trying to debug an issue on a clients machine. The problem is that the problem is a runtime error with very little clue as to where it is. It is an intermittent problem. I know ADL allows me to run the application in a debug mode. The problem is that to tell the user to download and manage the ADL invokation is going to be very difficult. It would be a lot easier if I could just give the end user one install/executable to install and run and then send me the trace of the issue. So what I'm looking for is easy steps for the client to be able to run the AIR app in debug mode. Downloading ADL and finding the install location of the app is going to be difficult to manage remotely with the end user.

Update: You have to make sure you are working with AIR 3.5 and Flash 11.5 and also include the following flag "-swf-version=18" in additional compiler settings. You then have to catch the global error as mentioned in the answer and it will show you the location of the error. No line numbers of course. Just routine names. Thanks a milion to Lee for the awsome answer.

Saviz
  • 677
  • 6
  • 19

3 Answers3

6

not a direct answer but if you publish for AIR3.5 (or 3.6 beta), you can get some debug info:

add a listener for uncaught RTEs to top level of your app:

this.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, globalErrorHandler);

and grab debug info from error in listener:

function globalErrorHandler(event:UncaughtErrorEvent):void
{
    var message:String;
    //check for runtime error
    if (event.error is Error)
        message = (event.error as Error).getStackTrace();
    //handle other errors
    else if (event.error is ErrorEvent)
        message = (event.error as ErrorEvent).text;
    else
        message = event.error.toString();
    //do something with message (eg display it in textfield)
    myTextfield.text = message;
}

getStackTrace will return a stack trace even for release AIR apps (as long as you use AIR3.5 or above).

user45623
  • 621
  • 4
  • 18
  • According to these docs: UncaughtErrorEvent was added in AIR 2. Why do you recommend an AIR3.5 or higher requirement? http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/events/UncaughtErrorEvent.html – JeffryHouser Dec 22 '12 at 04:36
  • 5
    quote from http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/Error.html#getStackTrace(): "For Flash Player 11.4 and earlier and AIR 3.4 and earlier, stack traces are only available when code is running in the debugger version of Flash Player or the AIR Debug Launcher (ADL). In non-debugger versions of those runtimes, calling this method returns null." –  Dec 22 '12 at 19:05
  • I'll +1 for that clarification. – JeffryHouser Dec 22 '12 at 19:10
  • Are you saying that I need to upgrade my SDK to AIR 3.5 abd Flash Player 11.5 in Flash Builder? Then publish to that. This will force the user to get the AIR 3.5 in their machine to run it and then I'll get the trace. Correct? – Saviz Dec 28 '12 at 01:55
  • getStackTrace has been available since AIR 1.0 so you can use any SDK for publishing, but user will need AIR 3.5 for it to work outside of debugging. So effectively yes; you do need to use 3.5 SDK - simply to force 3.5 on your users. –  Dec 29 '12 at 19:55
  • So I installed the latest AIR 3.5 on my machine. I didn't change how I build my app but simply added the global error and stacktrace code above to it. I also cause a run time error on purpose to see the behavior. It did not work. As in the stacktrace is null. Nothing shows up. – Saviz Jan 12 '13 at 03:11
  • "I didn't change how I build my app" - did you change the namespace to 3.5 in the app descriptor file? –  Jan 12 '13 at 12:14
  • If I change that it says it is invalid. Now I'm working on installing 3.5 in my Flash Builder 4.6 but from my googling it doesn't seem to be a straight forward process. Reading some blogs to figure it out. If you know of the steps please share and thank you for all your help. – Saviz Jan 12 '13 at 18:40
  • This talks about 3.4 but instructions good for any AIR version: http://helpx.adobe.com/x-productkb/multi/how-overlay-air-sdk-flex-sdk.html –  Jan 12 '13 at 18:53
  • So the install of AIR 3.5 in flash builder works and I can compile with namespace set to 3.5. Still no luck on getting the stacktrace. I've built a simple app to demonstrate here http://savizartang.com/runtimeerror/TestRuntimeError.zip the build .air file is here: http://savizartang.com/runtimeerror/TestRuntimeError.air – Saviz Jan 12 '13 at 20:24
  • 1
    Ok, sussed it - i put "-swf-version=18" in the additional compiler settings and it works. Not sure why thats needed; setting namespace to AIR3.5 in app descriptor file should be sufficient to force it to compile to 3.5, but i guess it isnt. –  Jan 14 '13 at 12:42
1

Without the SDK Tools; I don't think it is possible to run an aIR app in debug mode. But, here are a few alternatives to consider:

  • The client must have some idea what is going on to cause the error, right? Can you give them a special build with Alert Boxes or logging or something to help isolate the error to a line of code?
  • Can you listen for the uncaughtException event? The event will give you the full stack trace ( Error.getStackTrace() ); which you could then log--possibly with other information. Then you just have to tell your client to "Go here" and "send me this file." Or even display the info in some Alert and have the user copy and paste it into an email to you. More info on uncaughtException here and here
Community
  • 1
  • 1
JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
0

check my post. Maybe it helps you to get stack trace with line numbers in a AIR release build. How can I get stacktrace for Adobe AIR global runtime errors in non-debug mode?

I use it in 2 big projects right now and it works very well.

Greetings

Community
  • 1
  • 1
Stefan Habacher
  • 153
  • 1
  • 8