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: //XamarinForms1.Droid.csproj: //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.

Sorry, this blog does not support comments.

I used various blog hosting services since this blog was established in 2005, but unfortunately they turned out to be unreliable in the long term and comment threads were lost in unavoidable transitions. At this time I don't want to enable third-party services for comments since it has become obvious in recent years that these providers invariably monetize information about their visitors and users.

Please use the links in the page footer to get in touch with me. I'm available for conversations on Keybase, Matrix, Mastodon or Twitter, as well as via email.