Xamarin.Forms And The Case of Failed NuGet Packages

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

The Problem:

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:

XF-NUGET-02

The solution:

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.

XF-NUGET-03

3) Wait till all packages are downloaded. Make sure the %appdata% folder contents all the necessary directories and files.

XF-NUGET-04

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.

XF-NUGET-05

Now run the project and it should run without any issues.

XF-NUEGT-06

Namaste,
Mayur Tendulkar

Published by

Mayur Tendulkar

Struggling Juggler

4 thoughts on “Xamarin.Forms And The Case of Failed NuGet Packages”

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

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.