1

Xamarin.Forms アプリ、Android ピースに Azure Mobile Center の使用を開始しました。

必要な 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: オブジェクト参照がオブジェクトのインスタンスに設定されていません」というメッセージが表示されます。Crashes と Analytics が正しく初期化されていないようです。MobileCenter は静的クラスであるため、初期化に影響する可能性があります。

どんな助けでも大歓迎です。ありがとうございました、

4

3 に答える 3

1

呼び出しを OnInitialized メソッドに移動します。

于 2017-01-25T15:29:16.457 に答える
0

I'm using in the app Prism to implement MVVM. I had a hunch that this might affects things; I've created a new project, without using Prism, and voila...I can see Analytics...finally!

The issue is in what way Prism affects the MobileCenter. I've updated the original question.

于 2017-01-23T13:17:05.630 に答える