Xamarin Android: Unhandled exceptions never received in Sentry console
See original GitHub issueI’m not sure how to configure the new unified Sentry Sdk in order for it to capture unhandled exceptions. I’ve spent a day attempting to get it to send out unhandled exceptions, but they don’t seem to work properly in a Xamarin Android app.
The initialization of Sentry is performed like this:
SentryClient = SentrySdk.Init(o => {
o.Dsn = new Dsn(AppConfig.SentryDSN);
o.Debug = true;
});
As per comments in #96 I added:
AppDomain.CurrentDomain.ProcessExit += (object sender, EventArgs e) => {
SentryClient.Dispose();
};
Then, elsewhere in the Android code (an Activity for example), given the following lines, I get two different results:
SentrySdk.CaptureException(new Exception("Manually thrown exception")); // this makes it to Sentry.
throw new Exception("Unhandled exception"); // adding this line causes neither exception to make it to Sentry.
In the application console, I can see information regarding the event:
Info: Capturing event.
Debug: Running processor on exception: Unhandled exception
Debug: Creating SentryStackTrace. isCurrentStackTrace: False.
Debug: Running main event processor on: Event <event-id>
Debug: Event queued up.
Info: Disposing the Hub.
Debug: Disposing SentryClient.
Debug: Disposing BackgroundWorker.
Debug: Event <event-id> in-flight to Sentry. #0 in queue.
Debug: Disposing scope.
Debug: Disposing SentryClient.
Randomly (at some point after playing around with various configurations), the Sentry console has received an event with <unlabeled event>
as its title, and “Discarded invalid value for parameter ‘exception’” in the processing errors, but we are unable to determine if this is unhandled or not?
Additionally, if I use o.DisableAppDomainUnhandledExceptionCapture()
and set up my own exception handler on AppDomain
these aren’t sent either!
Is there anything obvious that I am doing wrong? Based on the documentation I don’t think there’s much more I should be doing.
Issue Analytics
- State:
- Created 5 years ago
- Comments:21 (9 by maintainers)
Top GitHub Comments
Sentry actually works for me in Xamarin.Forms. Only tested on iOS so far, but exceptions are being captured.
Just added to a
Xamarin.Android
app here: https://github.com/getsentry/symbol-collector/blob/dc542e3dfb7b63e4533c4c34d2cd11535c66b490/src/SymbolCollector.Android/MainActivity.cs#L214-L282