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
Did you upgrade Xamarin Forms to a version compatible with 23.3?
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.
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!
Try the following:
I don't guarantee that it will definitely work. But it is one of the possible solutions.
...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? :-(
This is really a blocker now. I had to roll back the whole update. If anyone has a solution, please share.
link to bugzilla: https://bugzilla.xamarin.com/show_bug.cgi?id=41380
Issue is not occurring after upgrading to Xamarin.Forms 2.2.0.45
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...
Did you do a full clean and rebuild? Try to delete the bin and obj folders. Usually cleans it up
This worked for me!
Worked for me as well. Thanks James.
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
work for me as well. Upgraded to 2.3.0.107
In my case, my styles.xml had issues
Changed API level to API 19 after that no issue before API 24
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 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.
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.
@JamesMontemagno , Thank you. It worked for me
I downgraded from 2.3.3.180 to 2.3.3.168 and now the app runs.
@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
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.
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
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.
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?
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.
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 ...
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 =(
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!!!
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!
This worked for me. Thank you.
@James Montemagno Thanks for your solution. It is worked fine.
In my case I just forgot to set the "android:theme", in "AndroidManifest.xml"
After setting the style it works perfectly.
// EDDY
Удаление папок bin и object помогло и мне
I deleted bin and obj folder from Android and Pcl project. Fixed
Hey, sorry to bring up an extraordinarily old thread but I have run into a similar issue.
I'm trying to figure out how to get my application to live in fullscreen and I found some places telling me to change my theme in MainActivity.cs to Theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen".
The application compiles and deploys but during debugging the error mentioned in this thread gets thrown.
base.OnCreate(savedInstanceState);
Android.Views.InflateException: 'Binary XML file line #1: Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar'
Below is the what I am editing in an attempt to get fullscreenmode.