I created a new solution to isolate this. This is my first time building and running on a actual device using Xamarin.
Device, Galaxy Note 3, is configured properly for debugging; I can make a blank android app, build it and run it on my device from visual studio no worries. The issue appears to be with Xamarin.Forms projects.
Exception is:
Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar
Code, exception location in bold:
using System; using Android.App; using Android.Content.PM; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; namespace App11.Droid { [Activity(Label = "App11", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity { protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; ** base.OnCreate(bundle);** global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new App()); } } }
Tried
I did some googling, in general it appears to be caused by using controls that don't exist after an update, or by dodgy XAML. But I'm using the boilerplate provided by the project type. The app does run correctly in the emulators.
Not sure what else to try.
Answers
You've updated things you shouldn't have. Common problem.
https://redpillxamarin.com/2016/12/23/202-starting-on-the-right-foot/
Thanks for you reply, I followed your link, started a new project and followed the directions.
Same problem occurs
@MarkOBrien
Ok.... Do me a favor.. Open the NuGet Package Manager for the solution.
What version of Xamarin.Forms is installed? Click on it and look in the right-hand pane to see the installed version.
And what are the installed versions of the Xamarin.Android.xxx packages?
@ClintStLaurent
Thanks for help so far.
xamarin.forms: 2.3.3.180
xamarin.Android.xxx 23.3.0
I took a couple of screenshots too. Any ideas ?
One last thought... maybe 5.0 on that device can't handle the themeing of
FormsAppCompatActivity
You could try inheriting form the older/simpler
FormsApplicationActivity
In
MainActivity.cs
comment out your existing class signature and put this on in its placepublic class MainActivity : FormsApplicationActivity
Hey thanks for your reply,
When I do that TabLayoutResource and ToolbarResource no longer exists in the current context. Commenting them out causes a null pointer exception.
I don't understand the what the boilerplate code does, so I don't know how to debug this. Below is my MainActivity.cs in the Android project.