So the other day I created a new Xamarin Forms solution in Visual Studio for one of my sample apps, and tried to build and run it.
Something to keep a note here my
- VS – Xamarin Version – 126.96.36.199
- VS – Xamarin Android Version – 188.8.131.52
- Xamarin Forms Version – 184.108.40.206
Build and Run, worked perfectly on iOS.
but on Android?
Then I tried running the Android app, and suddenly at runtime, KABOOM!
Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar…
Without even any build errors, a fresh out of the box project in Visual Studio!
It seemed like some Android dlls were missing in the runtime, something to do with Toolbar. 😮
This didn’t make any sense because I haven’t done any modifications to the project or even written any single line of code in the project, this was just a fresh out of the box Xamarin Forms solution.
So as usual I tried Clean & Rebuild, Restart VS, Restart the PC and so on many other random stuff. But still couldn’t figure out.
A WEIRD SOLUTION!
So as of a final destination I tried downgrading the Xamarin Forms version in the solution, and BOOM! IT WORKED!
So I thought may be this was a bug in the Xamarin Forms version I was using, but just to clarify it I upgraded the Xamarin Forms version back to the original version.
and BOOM! IT WORKED! 😀
Right Click on the Solution -> Manage Nugest Packages -> Select Xamarin.Forms package -> Tick on all the Projects in your Solution -> go to the Version selector -> select a lower Xamarin.Forms version and click Install -> restart VS -> Clean & Rebuild
Then do the same process but when you’re selecting the Xamarin.Forms version, make sure to select the one you had originally at first place when you created your solution! 😉
Although this doesn’t really make any sense why it would throw such a runtime error, fresh out of the box, and then magically fixes after downgrading and upgrading back the Xamarin Forms version in the solution, but I’m guessing its something to do with the Xamarin Extension for Visual Studio, which might be messing up with adding some Android dependencies to the solution.
Anyways, I just posted this in any case if you ever came across such a situation yourself! 😀