【发布时间】:2017-01-20 14:10:16
【问题描述】:
我已经开始将 Azure Mobile Center 用于 Xamarin.Forms 应用程序,用于 Android 部分。
我已添加所需的 Mobile Center SDK 调用,但在 Analytics 中仍然看不到任何内容。请注意,我可以正确构建和分发应用程序。
这就是 App.xams.cs 中的 App() 构造函数的样子:
public App()
{
InitializeComponent();
MobileCenter.Start(typeof(Analytics), typeof(Crashes));
MobileCenter.LogLevel = LogLevel.Verbose;
}
我还在 MainActivity.cs 的 OnCreate 事件中添加了配置调用
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.tabs;
ToolbarResource = Resource.Layout.toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
MobileCenter.Configure("my_app_id");
LoadApplication(new App(new AndroidInitializer()));
}
经过几次测试,Prism 似乎在某种程度上影响了 MobileCenter 类。 App() 构造函数没有被调用,所以我将它添加到现有的构造函数中:
public App(IPlatformInitializer initializer = null) : base(initializer) {
MobileCenter.Start(typeof(Analytics), typeof(Crashes));
}
但我收到“System.NullReferenceException:对象引用未设置为对象的实例”。似乎崩溃和分析未正确初始化。 MobileCenter 是一个静态类,因此可能会影响其初始化。
感谢任何帮助。 谢谢,
【问题讨论】:
-
您是否在同一应用程序中使用任何其他崩溃报告工具,例如 Hockeyapp、Xamarin.Insights、Crashalytics 等?
-
您好,为了避免丢失一些调试日志,您应该在调用
Configure之前移动MobileCenter.LogLevel = LogLevel.Verbose。然后要么使用adb bugreport创建一个包含所有日志的调试文件,要么手动提取标签以MobileCenter开头的所有日志,以便我们对其进行调查。 -
我不使用其他崩溃报告工具。我将转移 LogLevel 电话并回复您。感谢大家的意见。
-
我看到你已经开了对讲票,你可以在那里上传日志。
标签: xamarin.forms prism mobile-center visual-studio-app-center