Android projects not building in Xamarin

I ran into this problem the other day where I updated Xamarin on my Mac and I was playing with various solutions that involved Android projects. I kept receiving this build error:

Error: /<path>/XamarinForms1.Droid.csproj: 
  /<path>/XamarinForms1.Droid.csproj could not import
  "$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" (XamarinForms1.Droid)

I played around a bit with different project types, thinking the problem was specific to one or several of them, but they all showed the same issue. I tried setting build output to diagnostic, cleaning everything and rebuilding, and it only over showed me the same issue again. Eventually I searched my hard drive for the Xamarin.Android.CSharp.targets file to help me find out what the folder for $(MSBuildExtensionsPath) was supposed to be and I found it in /Library/Frameworks/Xamarin.Android.framework/Versions/6.0.1-10/lib/xbuild/Xamarin/Android/Xamarin.Android.CSharp.targets. Links in /Library/Frameworks/Xamarin.Android.framework/Versions appeared correct as well:

> ll /Library/Frameworks/Xamarin.Android.framework/Versions
total 8
drwxr-xr-x   3 root  wheel  102  6 Jan  2015 4.12.3-3
drwxr-xr-x   3 root  wheel  102  2 Jul  2015 4.20.0-28
drwxr-xr-x   3 root  wheel  102 17 May  2014 4.8.0-13
drwxr-xr-x   3 root  wheel  102 14 Sep 12:30 5.1.4-16
drwxr-xr-x   3 root  wheel  102  1 Feb 14:46 5.1.6-7
drwxr-xr-x  10 root  wheel  340  1 Feb 14:46 6.0.1-10
lrwxr-xr-x   1 root  wheel    8  1 Feb 14:46 Current -> 6.0.1-10

I was in touch with Xamarin support about this, and they didn’t know what the problem was. I ended up fixing the problem by reinstalling the Xamarin Android package — nice to see the usual restart technique still works 🙂

Afterwards, I came up with an idea for what might have triggered this: while I was playing around with .NET Core, I had uninstalled and then reinstalled Mono on my system. This didn’t appear to be a problem for other parts of Xamarin and I was able to build some demo command line solutions just fine, as well as other project types like iOS ones. But perhaps something got mixed up in the process anyway, for the Android package? Possible, I guess.

2 Comments on Android projects not building in Xamarin

  1. How did you reinstall Xamarin Android Package in Mac? I am getting the same error after downgrading my version of Mono

    Like

    • Good question… from the top of my head, I may have used the original installer? Or maybe there was a way in Xamarin Studio to see all the installed packages and do something from there?

      Like

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s