Microsoft.AppCenter.Crashes 未检测到 Xamarin.Forms iOS 项目上的崩溃

问题描述 投票:0回答:2

我最近尝试实现 Microsoft.AppCenter.Crashes 来帮助跟踪我团队的 Xamarin.Forms 应用程序中的崩溃情况。然而,当我们的 iOS 项目发生崩溃时,AppCenter 永远不会检测到它。我创建了以下用于设置和检查的函数,该函数在我们的中心项目的 App.xaml.cs 应用构造函数开始附近被调用:

private async Task CheckForPreviousCrash()
    {
        //Setup AppCenter
        await Xamarin.Forms.Device.InvokeOnMainThreadAsync(() =>
        {
            //Keys changed in StackOverflow post for security reasons.
            AppCenter.Start("ios=########-####-####-####-############;android=########-####-####-####-############;uwp=########-####-####-####-############", typeof(Crashes));
            AppCenter.IsNetworkRequestsAllowed = false; //Prevents sending user data to Microsoft. Required by company
        });

        //Make sure AppCenter is working
        bool isEnabled = await Crashes.IsEnabledAsync();
        if (!isEnabled)
        {
            _logger.LogError("AppCenter could not be started");
        }
        else
        {
            //Check for memory leak warnings
            bool memoryIssue = await Crashes.HasReceivedMemoryWarningInLastSessionAsync();
            if (memoryIssue)
            {
                _logger.LogError("AppCenter detected a memory warning in the last session");
            }

            //Check for crash info
            bool crashed = await Crashes.HasCrashedInLastSessionAsync();
            if (crashed)
            {
                var report = await Crashes.GetLastSessionCrashReportAsync();
                _logger.LogCrashReport(report);
            }

            //If AppCenter detected no issues in the last session, log an "all clear" message
            if (!memoryIssue && !crashed)
            {
                _logger.LogInformation("AppCenter did not detect a crash in the last session");
            }
        }
    }

我已经使用

Crashes.GenerateTestCrash()
函数测试了这段代码,这是我的团队正在尝试解决的崩溃之一,也是一个永远调用自身的简单递归函数。在 iOS 上运行时,我们的日志将始终显示“AppCenter 在上次会话中未检测到崩溃”消息,无论是否发生崩溃。任何帮助确定可能导致此问题的原因将不胜感激。

备注:

  • iOS 项目始终在不附加调试器的情况下运行。我知道如果 iOS 附加了调试器,则不会生成崩溃报告的规则 使用调试和发布模式构建时可以看到这一点
  • 此代码在我们的 Android 和 UWP 项目上按预期工作
  • iOS 项目始终通过
  • isEnabled
  • 检查
    这正在运行 AppCenter 和 AppCenter。崩溃版本 4.5.0
  • 它在 iOS 15.2.1 上的第 7 代 iPad 上运行
  • 编辑:针对建议答案的额外注释:

用于构建 iOS 项目的 Mac 运行的是 macOS 11.6.2
  • 项目是使用 XCode 13.2.1 构建的
  • Xamarin Forms 项目是在 Visual Studio 2019 16.11.7 中构建的,并通过 Visual Studio 的“与 Mac 配对”功能发送到连接的 Mac
  • 没有其他库用于崩溃报告(最接近的是 Serilog,它应该只处理日志记录)
  • 我们不使用CocoaPods来集成AppCenter
c# xamarin xamarin.forms visual-studio-app-center
2个回答
0
投票

-您的 iOS 项目是在 macOS 版本 10.14.4 或更高版本上的 Xcode 11 或更高版本中设置的。

-您的目标设备运行在 iOS 9.0 或更高版本上。

-您没有使用任何其他提供崩溃报告功能的库(仅适用于应用程序中心崩溃)。

-如果您使用 CocoaPods 集成 App Center,则需要 CocoaPods 1.10 或更高版本。

App Center SDK 分析和崩溃通过 XCFramework 或 SwiftPM 与 Mac Catalyst 兼容。

以下是有关 iOS 上应用程序中心崩溃的更多详细信息

https://learn.microsoft.com/en-us/appcenter/sdk/getting-started/ios


0
投票

© www.soinside.com 2019 - 2024. All rights reserved.