Error inflating class android.support.v7.widget.Toolbar after updaring to v7.AppCompat Version 23.3

I am creating a Xamarin Forms Project and using android.support.v7.widget.Toolbar with FormsAppCompatActivity. The code I'm posting below was working with Xamarin.Android.Support.v7.AppCompat Version: 23.0.1.3

But after I upgraded to 23.3.0 this has started throwing Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.toolbar exception.

Here is my code for MainActivity

[Activity(Label = "AppMob.Client", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {

        protected override void OnCreate(Bundle bundle)
        {
            FormsAppCompatActivity.ToolbarResource = Resource.Layout.toolbar;
            FormsAppCompatActivity.TabLayoutResource = Resource.Layout.tabs;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            Xamarin.FormsMaps.Init(this,bundle);                        
            GoogleAnalyticsHelper.GetGASInstance().Initialize_NativeGAS(Application.Context);  //For GA initialization
            LoadApplication(new App());
        }
}

This is my code for Resource.Layout.toolbar

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:layout_scrollFlags="scroll|enterAlways" />

Posts

  • AdamMeaneyAdamMeaney USMember ✭✭✭✭✭

    Did you upgrade Xamarin Forms to a version compatible with 23.3?

  • AbhimanyuSinghalAbhimanyuSinghal INMember ✭✭
    edited May 2016

    I have updated Xamarin.Forms to 2.2.0.31

    Dependencies for this version of Xamarin Forms mention:
    MonoAndroid 1.0 Xamarin.Android.Support.v4 (= 23.3.0)
    Xamarin.Android.Support.Design (= 23.3.0)
    Xamarin.Android.Support.v7.AppCompat (= 23.3.0)
    Xamarin.Android.Support.v7.CardView (= 23.3.0)
    Xamarin.Android.Support.v7.MediaRouter (= 23.3.0)

    it should thus be compatible with 23.3.

  • andrekibaandrekiba ITUniversity ✭✭

    Hi, I have the same problem with Xamarin.Forms 2.3.0.38-pre2 compatible with Xamarin.Android.Support.v7.AppCompat (= 23.3.0). Have you found a solution? Thanks!

  • andrekibaandrekiba ITUniversity ✭✭

    ...already done without success! :-( And the project has 36 nuget packages...very boring! Same error with Visual Studio on Parallels and Xamarin Studio on mac.

  • Has anyone had the same problem? :-(

  • AbhimanyuSinghalAbhimanyuSinghal INMember ✭✭

    This is really a blocker now. I had to roll back the whole update. If anyone has a solution, please share.

  • AbhimanyuSinghalAbhimanyuSinghal INMember ✭✭

    Issue is not occurring after upgrading to Xamarin.Forms 2.2.0.45

  • andrekibaandrekiba ITUniversity ✭✭

    Not here... :-(
    I upgraded to 2.3.0.46 pre3 (I need beta channel for some features) and the problem still persists...
    Please Xamarin help...

  • CodeJenksCodeJenks USMember

    @JamesMontemagno said:
    Did you do a full clean and rebuild? Try to delete the bin and obj folders. Usually cleans it up

    This worked for me!

  • DustinLindgrenDustinLindgren USUniversity

    @JamesMontemagno said:
    Did you do a full clean and rebuild? Try to delete the bin and obj folders. Usually cleans it up

    Worked for me as well. Thanks James.

  • Jason_DeBoeverJason_DeBoever USXamarin Team, University, XamUProfessors Xamurai

    In some cases this is just caused by missing the the android:theme in the Application tag of the android manifest.

    Additional info here: https://bugzilla.xamarin.com/show_bug.cgi?id=41380

  • RORURORU GBMember ✭✭

    @JamesMontemagno said:
    Did you do a full clean and rebuild? Try to delete the bin and obj folders. Usually cleans it up

    work for me as well. Upgraded to 2.3.0.107

  • KorayemKorayem EGMember ✭✭

    In my case, my styles.xml had issues

  • Changed API level to API 19 after that no issue before API 24

  • ManojShuklaManojShukla USMember

    I GOT THE SAME ERROR, BUT TRYING ALL DIFFERENT THINGS SUGGESTED IN DIFFERENT THREADS IN DIFFERENT LOCATIONS I TRIED BELOW.

    THIS WORKED FOR ME.

    DELETED "Xamarin.Android.Support.v7.AppCompat" FOLDER FROM LOCATION
    "C:\Users\AppData\Local\Xamarin"

    THIS IS FOR WINDOWS NOT SURE ABOUT IF YOU ARE DEVELOPING IN MAC MACHINE

  • MichaelChengMichaelCheng SGMember ✭✭
    edited January 2017

    I found that this error occurs only when running on an API 22 virtual device. It doesn't occur when I deploy to an API 19 virtual device. I'm using the default blank project generated by VS2015 without any modifications.

  • IamJohnny45IamJohnny45 USMember

    I have the same issue and cleaning the project, deleting obj/bin did not help. What I have discovered is that certain API targets don't work and that means it's likely a bug in "Xamarin.Android.Support.v7.AppCompat".

    Specifically I get the error when trying to debug on Android 5.0 - API 21. Both the Galaxy S4 emulator and physical device have the same error. However, Android 4.2 - API 17, and Android 6.0 - API 21 both work fine. For now I will debug on a working emulator but hopefully this gets fixed soon.

  • Basit-ABKBasit-ABK USMember

    @JamesMontemagno , Thank you. It worked for me :smile:

  • anveanve DEMember ✭✭✭

    I downgraded from 2.3.3.180 to 2.3.3.168 and now the app runs.

  • oarrivioarrivi USMember

    @anve You're right. It works by downgrading from 2.3.3.180 to 2.3.3.168

    I was deploying to a Samsung tablet with Api level 22 and threw the same error.
    After downgraded, it worked.

  • The above suggestion worked for me as well. However, at the moment nothing works anymore... not even when I create an app with the wizard and run it immediately. The Xamarin environment in combination with Visual Studio 2015 seems to be very unstable

  • pallavboharapallavbohara USMember ✭✭

    in my case issue was this --

    Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar

    and switching from Virtual device API 22 to API 19 solved the issue.

  • TechieRathoreTechieRathore INUniversity ✭✭

    I also faced same issue in Xamarin Forms App. the issue was solved by downgrading Xamarin Forms from 2.3.3.180 to 2.3.3.175 which I got from this URL https://bugzilla.xamarin.com/show_bug.cgi?id=41380

  • JCKennedyJCKennedy USMember

    I encountered same problem but I was able to solve the problem by running the project in API > 22 (Android 6+) or < 22 (Android 4).
    That error usually comes up after you update Xamarin.Forms to version 23.3.x.x and attempt running the project on API 22.

  • Ben.2646Ben.2646 USMember ✭✭

    I'm facing the same problem. Does that mean that Android 22 users will not be able tu use my app?
    Is there any hope to see a fix in a near futur?
    Who should be contacted?

  • HannaAzizHannaAziz MYMember

    Facing the same problem, I had tried all the solution mention above, but no luck, found out that when I updating the Xamarin Form to 2.3.3.193 by using NuGet package manager, after the installation, restart the visual studio, clean the solution and rebuild the solution. After that, when I try to debug to my device which is android 5.1 API 21 and praise to God it works!

    Thanks, all.

  • AugustinBockenAugustinBocken USMember ✭✭

    @ManojShukla said:
    I GOT THE SAME ERROR, BUT TRYING ALL DIFFERENT THINGS SUGGESTED IN DIFFERENT THREADS IN DIFFERENT LOCATIONS I TRIED BELOW.

    THIS WORKED FOR ME.

    DELETED "Xamarin.Android.Support.v7.AppCompat" FOLDER FROM LOCATION
    "C:\Users\AppData\Local\Xamarin"

    THIS IS FOR WINDOWS NOT SURE ABOUT IF YOU ARE DEVELOPING IN MAC MACHINE

    I tried everything else and it's the only solution that worked for me !
    I'm on Android 5.1 - API 22

    The folder appeared after the next build, so i suppose the error could come back ...

  • justwooperjustwooper MXMember ✭✭

    nothing worked for me, i tried to downgrade xamarin forms and nothing, tried to upgrade and nothing, tried deleting appcompat and nothing, i dont know what else to do =(

  • geozedgeozed ARMember ✭✭

    I'm facing de same error. I was using Xamarin.Forms.2.3.3.175 version and now I've upgraded to Xamarin.Forms.2.3.3.193 version. Then it works successfullly!!!

  • JimmyGarridoJimmyGarrido USXamarin Team Xamurai

    Hey all! Recent occurrences of this error message or similar ones were most likely caused by a bug in the templates where not all the dependencies for Forms were added in the Android project. This is why updating/downgrading the Forms package would resolve the issue as it would pull in the correct dependencies.

    This bug has been fixed in the C9 stable release so if you are encountering this error or similar issues with the latest version of Xamarin, please create a new thread and provide as much detail as possible so we can look into it. Thanks!

    @justwooper As mentioned above, can you open a new thread for your issue and include the full text of any errors you may be seeing and also the Forms version you are using and your IDE version information? Thanks!

  • KarunakarBhogyariKarunakarBhogyari USMember ✭✭

    @ShantimohanElchuri said:
    Try the following:

      >
    1. Manually remove each of the NuGet package one by one in the Android project only. You may have to do multiple passes of removing them due to dependency.
    2. >
    3. Restart VS
    4. >
    5. Then just add Xamarin.Forms package only. All the necessary packages will be added automatically.
    6. >
    7. Clean and rebuild the project.
    8. >

    I don't guarantee that it will definitely work. But it is one of the possible solutions.

    This worked for me. Thank you.

  • HemalathaMarikumarHemalathaMarikumar USMember ✭✭

    @James Montemagno Thanks for your solution. It is worked fine.

  • HemalathaMarikumarHemalathaMarikumar USMember ✭✭

    @JamesMontemagno said:
    Did you do a full clean and rebuild? Try to delete the bin and obj folders. Usually cleans it up

  • EasyEddyEasyEddy USMember ✭✭
    edited August 2017

    In my case I just forgot to set the "android:theme", in "AndroidManifest.xml"

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.sample.app">
        <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
        <application android:label="SampleApp" android:icon="@drawable/icon" android:theme="@style/YourTheme"></application>
    </manifest>
    </code>
    

    After setting the style it works perfectly.

    // EDDY

  • Удаление папок bin и object помогло и мне

  • TugbaSahinTugbaSahin USMember ✭✭

    I deleted bin and obj folder from Android and Pcl project. Fixed

Sign In or Register to comment.