Fixing “Could not load assembly Xamarin.Android.Support.Fragment” after upgrading to Xamarin.Forms 3.0 in Visual Studio 2017

While working on upgrading an existing project from Xamarin.Forms 2.3 to Xamarin.Forms 3.0 the following, incredibly baffling, error was thrown during the build phase:

Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly ‘Xamarin.Android.Support.Fragment, Version=, Culture=neutral, PublicKeyToken=’. Perhaps it doesn’t exist in the Mono for Android profile?
File name: ‘Xamarin.Android.Support.Fragment.dll’   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)   at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver) EdgeApp.Droid


The fix that worked for me – Uninstalling Xamarin.Forms then reinstalling:

  1. Document all Nuget packages that depend on Xamarin.Forms – their versions and what project(s) they’re installed in.
  2. Also document the version and which projects Xamarin.Forms is installed in.
  3. Uninstall the packages from step 1 from all projects
  4. Uninstall Xamarin.Forms from all projects
  5. Reinstall Xamarin.Forms
  6. Reinstall packages that depended on Xamarin.Forms
  7. Rebuild solution


Other suggested fixes:

Refresh Nuget package cache

First, close your solution.

In your solution, normally at the top level, there will be a “packages” folder. You can safely delete the contents of this folder unless you have manually placed packages here. If you’re worried then take a backup first.

Now you can reopen your solution. Visual Studio 2017 should automatically restore all packages. Once it has done this then you can attempt to rebuild your solution.


Reinstall Nuget packages

In Visual Studio 2017:
Tools -> Nuget Package Manager -> Package Manager Console

For each project run the following command:

Update-Package -reinstall

Once the command(s) have completed running you can attempt to rebuild your solution.

Update Target Android version

Our project was targeting an older version of Android originally (6.0) and updating our project to target the latest stable version (8.1) didn’t resolve the error. However it may help you.

In Visual Studio 2017, right click on your Android project and select “Properties”. On the left hand side of the window that opened, click on “Android Manifest”. In “Target Android Version” select a newer version that what you’re currently targeting.

You can also unload your solution and edit the Android project .csproj file and look for the <TargetFrameworkVersion> element. You can update this string to a valid Android version e.g. <TargetFrameworkVersion>v8.1</TargetFrameworkVersion> for Oreo.

Reload your solution, clean the solution, then rebuild.


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

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