Xamarin.Android does not track trace in async method

Can anyone find some workaround for this error:

https://bugzilla.xamarin.com/show_bug.cgi?id=30513

?

This is driving me crazy ... the screenshot is the exception report I got from the async method.

enter image description here

+3


source to share


2 answers


Okey guys, so I found a workaround for this error, here's step by step what to do to deal with it and let Xamarin.Insights work.

  • Add text file to Android project (name doesn't matter) and set it from "Content" in properties to " AndroidEnvironment "
  • In the text file you created, add this flag: XA_BROKEN_EXCEPTION_TRANSITIONS = true - this flag means we will use the old Xamarin.Android 4.x exception handling
  • Then add a global Android exception handler to your droid project, it will handle Android exceptions which would normally crash the app before your Xamarin.Insights (or other reporting tool) can do some work.


AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) => { args.Handled = true; }

And voila, Xamarin.Insights is ready to work for you :)

0


source


Here is another solution that worked for me. Just add this handler to your application or main event

AndroidEnvironment.UnhandledExceptionRaiser += delegate(object sender, RaiseThrowableEventArgs args){
            typeof (System.Exception).GetField("stack_trace", BindingFlags.NonPublic | BindingFlags.Instance)
                .SetValue(args.Exception, null);
            throw args.Exception;
        };

      



The explanation is here in the last post https://forums.xamarin.com/discussion/45219/stack-trace-not-captured-properly

+1


source







All Articles