Xamarin Forms: Crash reports are not showing in App Center for xamarin forms application

Sreejith Sreenivasan 671 Reputation points
2023-07-28T15:26:35.6666667+00:00

I have implemented the App Center crash analytics into my Xamarin forms application.

Step 1: Installed Microsoft.AppCenter.Analytics and Microsoft.AppCenter.Crashes packages.

Step 2: Added below line on App.xaml.cs file constructor.

AppCenter.Start("ios={Your App Secret};android={Your App Secret}", typeof(Analytics), typeof(Crashes));

Step 3: Created a crash scenarios on Settings page and break the app like below.

string name = null;
public SettingsPage(string type)
{
	InitializeComponent();
	Debug.WriteLine("length:>>" + name.ToString().Length);
}

When I run the App and open the settings page the below output is showing on Android and iOS platforms.

Android

20:02:23:947 System.NullReferenceException: 'Object reference not set to an instance of an object.' 20:02:23:947 20:02:25:743 [AppCenterXamarinCrashes] Unhandled Exception from source=AppDomain 20:02:25:743 [AppCenterXamarinCrashes] System.NullReferenceException: Object reference not set to an instance of an object. 20:02:25:743 [AppCenterXamarinCrashes] at CallerBee.Views.SettingsPage..ctor (System.String type) [0x0002a] in E:\My Projects\Xamarin\listpm-callerbee-app\CallerBee\CallerBee\Views\User Pages\SettingsPage.xaml.cs:43 20:02:25:743 [AppCenterXamarinCrashes] at MyAppName.Views.Home.HomeTabPage.HomeOptionsTapped (System.Object sender, Xamarin.Forms.ItemTappedEventArgs e) [0x0060a] in E:\My Projects\Xamarin\listpm-callerbee-app\CallerBee\CallerBee\Views\Home\HomeTabPage.xaml.cs:270 20:02:25:744 [AppCenterXamarinCrashes] at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 20:02:25:744 [AppCenterXamarinCrashes] at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36 20:02:25:744 [AppCenterXamarinCrashes] at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 20:02:25:744 [AppCenterXamarinCrashes] at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-33/mcw/Java.Lang.IRunnable.cs:84 20:02:25:744 [AppCenterXamarinCrashes] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V (_JniMarshal_PP_V callback, System.IntPtr jnienv, System.IntPtr klazz) [0x00005] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22 20:02:25:744 [AppCenterXamarinCrashes] at (wrapper native-to-managed) Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(intptr,intptr) 20:02:25:823 [mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object. 20:02:25:823 [mono-rt] at CallerBee.Views.SettingsPage..ctor (System.String type) [0x0002a] in E:\My Projects\Xamarin\listpm-callerbee-app\CallerBee\CallerBee\Views\User Pages\SettingsPage.xaml.cs:43 20:02:25:823 [mono-rt] at MyAppName.Views.Home.HomeTabPage.HomeOptionsTapped (System.Object sender, Xamarin.Forms.ItemTappedEventArgs e) [0x0060a] in E:\My Projects\Xamarin\listpm-callerbee-app\CallerBee\CallerBee\Views\Home\HomeTabPage.xaml.cs:270 20:02:25:823 [mono-rt] at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 20:02:25:823 [mono-rt] at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36 20:02:25:823 [mono-rt] at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 20:02:25:823 [mono-rt] at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-33/mcw/Java.Lang.IRunnable.cs:84 20:02:25:823 [mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V (_JniMarshal_PP_V callback, System.IntPtr jnienv, System.IntPtr klazz) [0x00005] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22 20:02:25:823 [mono-rt] at (wrapper native-to-managed) Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(intptr,intptr)

iOS

2023-07-28 20:34:12.085 MyAppName.iOS[490:34249] [AppCenter] ERROR: -[MSACChannelUnitDefault sendLogContainer:]_block_invoke/230 Log(s) sent with failure, batch Id:28F8F08D-8A0F-457D-8B96-2A375E9023F6, status code:401
2023-07-28 20:34:12.089 MyAppName.iOS[490:34249] [AppCenter] ERROR: -[MSACChannelUnitDefault sendLogContainer:]_block_invoke/243 Fatal error encountered; shutting down channel unit with group ID AppCenter
2023-07-28 20:34:12.090 MyAppName.iOS[490:34249] [AppCenter] ERROR: -[MSACChannelUnitDefault sendLogContainer:]_block_invoke/230 Log(s) sent with failure, batch Id:EC474EB4-B4A3-4845-84E6-F94FD7BF0C6D, status code:0
2023-07-28 20:34:32.018 MyAppName.iOS[490:34252] [AppCenterXamarinCrashes] ERROR: +[MSACWrapperLogger MSACWrapperLog:tag:level:]/10 Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at MyAppName.Views.SettingsPage..ctor (System.String type) [0x0002a] in /Users/MyCompanyName/Projects/MyAppName-app/MyAppName/MyAppName/Views/User Pages/SettingsPage.xaml.cs:43 
  at MyAppName.Views.Home.HomeTabPage.HomeOptionsTapped (System.Object sender, Xamarin.Forms.ItemTappedEventArgs e) [0x0060a] in /Users/MyCompanyName/Projects/listpm-MyAppName-app/MyAppName/MyAppName/Views/Home/HomeTabPage.xaml.cs:270 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 
  at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/Foundation/NSAction.cs:176 
  at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,intptr,intptr,intptr,intptr&)
  at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/UIKit/UIApplication.cs:58 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/UIKit/UIApplication.cs:84 
  at MyAppName.iO

But when I open the Analytics in App Center website nothing is listing there for both applications. I have created different projects for android and ios and added the secret on the app side.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,254 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sreejith Sreenivasan 671 Reputation points
    2023-07-31T11:22:10.8333333+00:00

    Tried without the curly braces and that solved my problem.

    AppCenter.Start("ios=xxxxxx;android=yyyyy;", typeof(Analytics), typeof(Crashes));
    

    Example:

    AppCenter.Start("android=ec1d1192-9c77-421c-b394-f0792bd229fa;" +
    "ios=dd8c6b50-d4aa-4c9c-a460-4e14f3eab623;",
    typeof(Analytics), typeof(Crashes));
    

    Go to the app center app > diagnostics > issues > Click on crash group, "you will see stack trace."

    If you want full crash logs, In the same page > click on reports > click on the any device that is showing > and then you will see the download button!

    0 comments No comments