Forum Xamarin.Android

Xamarin: Android Navigation View Inflation Error in Navigation Drawer Activity

ChetanGudisagarChetanGudisagar USMember
edited June 2016 in Xamarin.Android

Unhandled Exception: Android.Views.InflateException: Binary XML file line #1: Error inflating class

Above error crops us when I use SetContentView(Resource.Layout.NavigationLayout);
I am calling Navigation Activity through Intent after a login activity(Main).
I have referred this page.
I haven't applied any themes so far and I have not used any string values.

I am running this in visual studio 2015 on Nexux 7 (Marshmallow) (Android 6.0 - API 23) and all packages are of version v23.3.0 and added from nuget.
I have listed my files for reference.

NavigationLayout.axml -
<?xml version="1.0" encoding="utf-8"?> < xmlns:android="" xmlns:app="" android:id="@+id/drawerlayout" android:layout_height="match_parent" android:layout_width="match_parent" android:fitsSystemWindows="true"> < android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:id="@+id/nav_view" app:menu="@menu/drawer" /> </>

NavigationActivity.cs -
`namespace NavigationDrawerApp
{ [Activity(Label = "NavigationActivity")]
public class NavigationActivity : Activity
protected override void OnCreate(Bundle savedInstanceState)

        var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);


drawer.xml -
<?xml version="1.0" encoding="utf-8" ?> <group xmlns:android="" android:checkable="true"> <item android:id="@+id/nav_item1" android:title="11"> </item> <item android:id="@+id/nav_item2" android:title="12"> </item> </group>

toolbar.xml -
<?xml version="1.0" encoding="utf-8" ?> < xmlns:android="" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content"> </>

packages.config -
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" /> <package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid60" /> <package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid60" /> <package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="monoandroid60" /> <package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="monoandroid60" /> <package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0<del></del>" targetFramework="monoandroid60" /> </packages>

AndroidManifest.xml -
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="16" /> <application android:label="NavigationDrawerApp"></application> </manifest>

Strings.xml -
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="Hello">Hello World, Click Me!</string> <string name="ApplicationName">NavigationDrawerApp</string> </resources>


  • EnglbachEnglbach VNMember ✭✭

    The toolbar must be lie inside drawerlayout

  • ChetanGudisagarChetanGudisagar USMember

    Thanks for looking into it. I tried that but still gives the error during run/deployment time :neutral:
    Unhandled Exception: Android.Views.InflateException: Binary XML file line #1: Error inflating class

    As it says error is in creating Navigation View class. It shows at this line in the project-

    Can anyone help?

  • Tom-PrattTom-Pratt GBMember ✭✭

    I get this error quite often when editing xml related to a NavigationView but find that it is solved by cleaning the solution.

  • ChetanGudisagarChetanGudisagar USMember

    I tried clean Solution. its not working even after that :neutral:

  • gyanvermagyanverma INMember

    Anyone having any solution ?? :(

  • I quite often get this error and resolved it by clean and rebuild the solution. But yesterday i discovered that it happens in release mode as well....

  • Jerome0626Jerome0626 BEMember

    I get this error and clean and rebuild doesn't fix the issue.
    It works on other developper Visual Studio but not on mine ... :(

  • BerayBentesenBerayBentesen TRUniversity ✭✭✭✭

    Anyone having this issue should set menu and header with code like this ;


    This issue also occurs on Android Studio - Native project the only solution is clean project - remove bin & obj folder - uninstall project from phone - rebuild and install.

    If other setup steps are applied correctly, it will work without any problem.

Sign In or Register to comment.