我正在使用 .NET MAUI 构建适用于 Android 和 IOS 的移动应用程序。
在模拟器上调试应用程序时没有问题。 但在物理设备 (Android) 中显示发布版本的启动屏幕几秒钟后,应用程序崩溃了。
我不知道如何记录此类问题,也不知道是什么导致了该问题。
编辑:我需要有关如何记录有关崩溃和导致崩溃的问题的详细信息的帮助。不是问题本身。
我建议使用 3pp 日志服务,例如 Sentry(其他也可用)
https://sentry.io/for/dotnet-maui/
这确实非常简单。 创建一个免费帐户并注册您的应用程序。 您将获得一个 DSN 代码,您需要存储它并将其添加到下面的应用程序中。
然后在你的
CreateMauiApp()
方法中添加这个
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
// Add this section anywhere on the builder:
.UseSentry(options =>
{
// The DSN is the only required setting.
options.Dsn = "Your DSN url value is entered here";
// Use debug mode if you want to see what the SDK is doing.
// Debug messages are written to stdout with Console.Writeline,
// and are viewable in your IDE's debug console or with 'adb logcat', etc.
// This option is not recommended when deploying your application.
options.Debug = true;
// Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing.
// We recommend adjusting this value in production.
options.TracesSampleRate = 1.0;
// Other Sentry options can be set here.
})
然后当你捕获异常时,只需将其记录到Sentry
catch (Exception ex)
{
SentrySdk.CaptureException(ex);
//Your normal logging & handling
}
它还将捕获未处理的异常,并具有许多功能使您能够自定义和丰富错误。