Common error conditions and how to resolve them
Error: "Unable to find a version of Xamarin.Forms compatible with..."
The following errors can appear in the Package Console window when updating all the Nuget packages in a Xamarin.Forms solution or in a Xamarin.Forms Android app project:
Attempting to resolve dependency 'Xamarin.Android.Support.v7.AppCompat (= 184.108.40.206)'. Attempting to resolve dependency 'Xamarin.Android.Support.v4 (= 220.127.116.11)'. Looking for updates for 'Xamarin.Android.Support.v7.MediaRouter'... Updating 'Xamarin.Android.Support.v7.MediaRouter' from version '18.104.22.168' to '22.214.171.124' in project 'Todo.Droid'. Updating 'Xamarin.Android.Support.v7.MediaRouter 126.96.36.199' to 'Xamarin.Android.Support.v7.MediaRouter 188.8.131.52' failed. Unable to find a version of 'Xamarin.Forms' that is compatible with 'Xamarin.Android.Support.v7.MediaRouter 184.108.40.206'.
What causes this error?
Visual Studio for Mac (or Visual Studio) may indicate that updates are available for the Xamarin.Forms Nuget packge and all its dependencies. In Xamarin Studio, the solution's Packages node might look like this (the version numbers might be different):
This error may occur if you attempt to update all the packages.
This is because with Android projects set to a target/compile version of Android 6.0 (API 23) or below, Xamarin.Forms has a hard dependency on specific versions of the Android support packages. Although updated versions of those packages may be available, Xamarin.Forms is not necessarily compatible with them.
In this case you should update only the Xamarin.Forms package as this will ensure that the dependencies remain on compatible versions. Other packages that you have added to your project may also be updated individually as long as they do not cause the Android support packages to update.
If you are using Xamarin.Forms 2.3.4 or higher and your Android project's target/compile version is set to Android 7.0 (API 24) or higher, then the hard dependencies mentioned above no longer apply and you may update the support packages independently of the Xamarin.Forms package.
Fix: Remove all packages, and re-add Xamarin.Forms
If the Xamarin.Android.Support packages have been updated to incompatible versions, the simplest fix is to:
- Manually delete all the Nuget packages in the Android project, then
- Re-add the Xamarin.Forms package.
This will automatically download the correct versions of the other packages.
To see a video of this process, refer to this forums post.