I am using the latest HockeyApp nuget package for xamarin to utilize Preseason. In the documentation for Preseason it states that I’ve got to put the following in my mainactivity for a native android application:
MetricsManager.register(this, getApplication());
I have used the following in my Xamarin Android Application:
MetricsManager.Register(Android.App.Application.Context, this.Application );
However i receive a very strange error and do not know how to fix it or if i am even calling the metrics manager appropriately.
Here is my code:
protected override void OnCreate(Bundle bundle)
{
try
{
base.OnCreate(bundle);
// Register the crash manager before Initializing the trace writer
HockeyApp.CrashManager.Register(this, AppId);
//Register to with the Update Manager
HockeyApp.UpdateManager.Register(this, AppId);
// Initialize the Trace Writer
HockeyApp.TraceWriter.Initialize();
// Wire up Unhandled Expcetion handler from Android
AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) =>
{
// Use the trace writer to log exceptions so HockeyApp finds them
HockeyApp.TraceWriter.WriteTrace(args.Exception);
args.Handled = true;
};
MetricsManager.Register(Android.App.Application.Context, new Android.App.Application());
Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
CheckForCrashes();
CheckForUpdates();
}
catch
{
}
}
private void CheckForCrashes()
{
CrashManager.Register(this, AppId);
}
private void CheckForUpdates()
{
//todo: Remove this for production!!
UpdateManager.Register(this, AppId);
}
Here is the error:
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.OnPrepareOptionsMenu (IMenu menu) [0x00000] in :0 at Android.App.Activity.n_OnPrepareOptionsMenu_Landroid_view_Menu_ (IntPtr jnienv, IntPtr native__this, IntPtr native_menu) [0x00011] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:4301 at (wrapper dynamic-method) System.Object:0ea0564e-2a6f-481c-ab24-cf222ecfff78 (intptr,intptr,intptr)