Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio App Center: crashes and errors not working on Xamarin iOS

In my Xamarin iOS app I enabled AppCenter's Analytics and Crash how explained here: https://learn.microsoft.com/en-us/appcenter/sdk/getting-started/xamarin

Analytics works, but I'm not able to see any crash/error on the Diagnostic section of App Center web console. In troubleshooting page there is written that on iOS cannot be more than a tool for exception handling, and this is the only one. In my app I enabled FCM so there is Firebase, I tried to remove any reference to Firebase but nothing changes.

Enabling AppCenter.LogLevel = LogLevel.Verbose; I can see that when app crashes AppCenter tries to store the exception ("Storing a log to Crashes"), but after I can see a "Found an empty buffer position". At the restart I see that SendingErrorReport callback is called, but SentErrorReport and FailedToSendErrorReport are ignored.

After AppCenter.Start I tried to call await Crashes.SetEnabledAsync(true). If I let it crash and when I reopen the app I call ErrorReport crashReport = await Crashes.GetLastSessionCrashReportAsync() crash report is always null.

In Symbols section I can read "You're awesome! There are no unsymbolicated crashes". I tried to compile in Debug and in Release. I tried to launch a new Exception and to use Crashes.GenerateTestCrash.

I didn't have any problem using Analytics and Crash with a Xamarin.Forms app.

like image 822
Mauro Piccotti Avatar asked Oct 19 '25 01:10

Mauro Piccotti


2 Answers

This kind configuration works me as well:

using Microsoft.AppCenter.Crashes;

AppCenter.Start(Settings.AppCenterConfigString, typeof(Analytics), typeof(Crashes) /*, typeof(Push)*/);
Crashes.NotifyUserConfirmation(UserConfirmation.AlwaysSend);

Custom Exception (Error) logging:

catch (Exception e) { Crashes.TrackError(e, ...); }

https://learn.microsoft.com/en-us/appcenter/sdk/crashes/xamarin#ask-for-the-users-consent-to-send-a-crash-log

like image 98
Artūras Paleičikas Avatar answered Oct 21 '25 21:10

Artūras Paleičikas


Finally after lot of hit and trial I have found that you have to override a different FinishedLaunching method, which provides UIApplication & NSDictionary params.

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            AppCenter.LogLevel = LogLevel.Verbose; //just so you can see in debug //that it is running successfully
            AppCenter.Start(#your app id#, typeof(Crashes));
}

You are welcome ;-)


  1. Error logs will be uploaded the next time app loads, so crash it on a button click, then close the app and remove it from recent apps.
  2. Start the app again and wait couple of moments, then see the web UI
  3. Depending upon the OS version you also have to add following code into the info.plist

    <key>NSAppTransportSecurity</key>
      <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
      </dict>
like image 28
AZ_ Avatar answered Oct 21 '25 20:10

AZ_