当我的StackTrace应用程序崩溃时,我试图保存我的错误消息和Xamarin.Android。
在Xamarin.iOS中,我可以简单地将我的主方法封装在一个尝试捕获块中,如您在下面的屏幕快照中所看到的:

由于Xamarin.Android中没有Main-Method (只是我的MainLauncher活动),所以我问自己,是否有类似的简单方法来记录异常。
发布于 2018-04-17 08:12:24
我找到了日志所有未处理异常的解决方案:
在我的MainLauncher活动中:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
AndroidEnvironment.UnhandledExceptionRaiser += HandleAndroidException;和
private void HandleAndroidException(object sender, RaiseThrowableEventArgs e)
{
e.Handled = true;
Logger = new LogUtils();
Logger.Log("ERROR: Unhandled Exception");
Logger.Log("MESSAGE: " + e.Exception.Message);
Logger.Log("STACKTRACE: " + e.Exception.StackTrace);
}https://stackoverflow.com/questions/49858101
复制相似问题