Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Xamarin Forms Woes

DZone's Guide to

Xamarin Forms Woes

Follow along with this tale of errors and hardships when trying to get a prototype of a Xamarin Forms app running, and see how it was resolved.

· Mobile Zone ·
Free Resource

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:

Image title

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...

Android SDK

Launch Android SDK Manager and install the latest (or a later) version:

Image title

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 are two things that were necessary here; the first was to make sure that this package was installed:

Install-Package Crosslight.Xamarin.Android.Support.v7.AppCompat

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':

Errors:
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=1.0.0.0, 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 than 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.

Image title

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:

    app:tabIndicatorColor="@android:color/white"
    app:tabGravity="fill"
    app:tabMode="fixed" />

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)!

Image title

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.

Topics:
mobile ,xamarin ,xamarin forms ,android

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}