When you create a Xamarin.Forms project, chances are there will be updates available for Xamarin.Forms libraries and associated packages. You can check for updates to NuGet packages manually or these will be restored before “build”.
When you create a new Xamarin.Forms app or open existing one, if you’ve fresh formatted machine with fresh VS and Xamarin installation, the build may last for longer than expected. The reason for this being, it downloads NuGet packages along with its dependencies like Android Support Packages. If in between, VS hangs or there are interruptions in network, you’ll see some errors in build like this:
Well, at first you may think it is issue with Xamarin or Visual Studio or NuGet. But this all has to do with lot of NuGet packages and their dependencies download. So it all depends on machine config and network connectivity. If ever you see above errors follow the below steps:
1) Start from fresh. Close Visual Studio instances and delete everything under %appdata%local/Xamarin (e.g. C:\Users\mayur\AppData\Local\Xamarin)
2) Launch Visual Studio and open the solution. Right click each project and update NuGet packages. Android is the one which will take longer to update.
3) Wait till all packages are downloaded. Make sure the %appdata% folder contents all the necessary directories and files.
4) Build the solution. And if you still get issues about some missing some resources. Open Android SDK Manager from Tools > Android and make sure right API levels (in this case API Level 23) is installed.
Now run the project and it should run without any issues.
4 thoughts on “Xamarin.Forms And The Case of Failed NuGet Packages”
Hi, I had this (especially with InitializeComponent()) a couple of times but it goes away when I open any xaml file and name the page with x:Name… In my case, they are false bugs because the whole things still compiles and works. But it comes up multiple times… not sure it is the same problem.
Are you using ReSharper like tools? Also you can check error window and filter it for build only. Not build + intellisense.