We need to initialize Xamarin.Essentials on Android by calling an initialization method. We do this by going through the following steps:
- In the Android project, open the MainActivity.cs file.
- Add the code in bold under the global::Xamarin.Forms.Forms.Init method:
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); LoadApplication(new App()); }
That's it. We are all good to go.