Xamarin Forms is one of those technologies that I keep meaning to play with… but then don’t. Anyway, this is the story of the day that I first did… the intention was to spend a Sunday afternoon getting a quick prototype of a Xamarin Forms app running… but instead, I encountered error after error.
In the end,all I ended up producing was this post!
The first error after creating a new app:
This gave me the impression that I might have the wrong version of Android; so off I went to install the latest JDK; from here.
Thus began a process that took hours to complete…
Launch Android SDK Manager and install the latest (or a later) version:
Amazingly, this did seem to fix (or at least, change) the error.
The next problem was a build error from the Android project:
Error: No resource found that matches the given name: attr 'colorAccent'
There’s two things that were necessary here; the first was to make sure that this package was installed:
And now we’re onto the next problem…
Suddenly, it decided there was an issue with some of the resources in the file ‘Tabbar.axml’:
1>C:\Code\MyApp\MyApp.Android\Resources\layout\Tabbar.axml : error APT0000: 1: error: No resource identifier found for attribute 'tabIndicatorColor' in package 'com.companyname.WizardGame'
1>C:\Code\MyApp\MyApp.Android\Resources\layout\Tabbar.axml : error APT0000: 1: error: No resource identifier found for attribute 'tabGravity' in package 'com.companyname.WizardGame'
1>C:\Code\MyApp\MyApp.Android\Resources\layout\Tabbar.axml : error APT0000: 1: error: No resource identifier found for attribute 'tabMode' in package 'com.companyname.WizardGame'
Taking inspiration from my Spectrum programming days, and having no clue what the hell was going on at this stage, I just deleted these lines… and got a different error:
error CS0012: The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=126.96.36.199, Culture=neutral, PublicKeyToken=null'.
This didn’t make much sense, but while I was messing around in the Package Manager screen, I decided to update the Xamarin.Forms package; for some reason, the latest version seems to be (numerically) older that the older one:
Giddy with the thrill of the update working without a new, spurious error, I updated everything! This required VS to be restarted at least once.
At this stage, the project started compiling… so before Xamarin regained its footing and thought of a new error, I added back in the code I’d removed:
Now it compiles!… But won’t deploy to Android
Xamarin was catching up with me – a new error now appeared:
1>Please select a valid device before running the application.
After a little help from a well-known search engine, I selected the emulation manager:
If you find yourself in this situation, then don’t keep clicking (despite no feedback at all, the manager does open in the background)!
Select one of the devices and start it:
And it now deploys… I didn’t get anything done, but I did manage to get Xamarin running on an Android emulator… so that’s something.