Error NU1107 Version conflict detected for Xamarin.AndroidX.Lifecycle.LiveData - xamarin

I get the following error:
Error NU1107 Version conflict detected for Xamarin.AndroidX.Lifecycle.LiveData.
Install/reference Xamarin.AndroidX.Lifecycle.LiveData 2.4.1.1 directly to project MyProject.Android to resolve this issue.
MyProject.Android -> Xamarin.GooglePlayServices.Ads 121.2.0 -> Xamarin.GooglePlayServices.Ads.Lite 121.2.0 ->
Xamarin.AndroidX.Work.Runtime 2.7.1.3 ->
Xamarin.AndroidX.Lifecycle.LiveData (>= 2.4.1.1)
MyProject.Android -> Xamarin.Forms 5.0.0.2515 -> Xamarin.AndroidX.Lifecycle.LiveData (>= 2.3.1.1 && < 2.4.0).
Which packages should I upgrade or downgrade in order to achieve compatibility?

I have created a new project to test the packages you mentioned. And I found two solutions:
Just use the following package in your project's android part:
Xamarin.AndroidX.Browser version 1.4.0.1
Xamarin.AndroidX.Lifecycle.LiveData version 2.4.1.1
Xamarin.GooglePlayServices.Ads version 121.2.0
Xamarin.Forms version 5.0.0.2515
This solution just adds the reference to the project's android part according to the error messages. And the project will build successfully even though there are still some warnings about the package.
The second solution:
use the Xamarin.Forms version 5.0.0.2545
and the Xamarin.GooglePlayServices.Ads version 120.4.0
The Xamarin.GooglePlayServices.Ads version 120.4.0 is the newest version which is compatible with the Xamarin.AndroidX.Browser (>= 1.3.0.6 && < 1.4.0). If you use the two packages above, there will not be any warnings or errors about the reference.

If you can, you should upgrade to Xamarin.Forms 5.0.0.2545. It allows for LiveData to be high enough. It's a minor upgrade for XF, so it shouldn't cause you any issues to upgrade.
If for whatever reason you can't upgrade Xamarin Forms, you'll need to downgrade GooglePlayServices.Ads to a version that allows for the lower Work.Runtime version which in turn allows for the lower LiveData version.

Related

Xamarin MSAL NuGet error - Version conflict detected for Xamarin.Android.Support.Compat

I'm trying to add the MSAL NuGet package https://www.nuget.org/packages/Microsoft.Identity.Client to a Xamarin forms project but keep getting the following error:
Package restore failed. Rolling back package changes for
'MobileApp.Android'.
Error NU1107 Version conflict detected for
Xamarin.Android.Support.Compat. Install/reference
Xamarin.Android.Support.Compat 27.0.2.1 directly to project
MobileApp.Android to resolve this issue.
MobileApp.Android -> Xamarin.Android.Support.v7.MediaRouter
27.0.2.1 -> Xamarin.Android.Support.v7.Palette 27.0.2.1 ->
Xamarin.Android.Support.Compat (= 27.0.2.1)
MobileApp.Android -> Microsoft.Identity.Client 2.2.0-preview ->
Xamarin.Android.Support.CustomTabs 27.0.2 -> Xamarin.Android.Support.Compat
(= 27.0.2).
I've tried clearing the NuGet cache from Visual Studio 2017 -> Tools -> Options -> NuGet Package Manager, and also manually clearing the cache by deleting the contents of the following folders:
%userprofile%\.nuget\packages
%localappdata%\NuGet\v3-cache
%temp%\NuGetScratch
%localappdata%\NuGet\plugins-cache
I've also tried creating a new blank project and just adding the NuGet package but continue to receive the same error. NuGet seems to working OK for other types of projects.
Any ideas much appreciated.
Xamarin MSAL NuGet error - Version conflict detected for Xamarin.Android.Support.Compat
This is nuget package version conflict issue.
To resolve this issue, you should install the package Xamarin.Android.Support.CustomTabs 27.0.2.1 at first, then install the package Microsoft.Identity.Client.
The reason for this issue:
Since you have already installed the package Xamarin.Android.Support.v7.MediaRouter
27.0.2.1 in your project, which have a indirect dependence Xamarin.Android.Support.Compat (= 27.0.2.1). When you install the package Microsoft.Identity.Client to the project, which also have a indirect dependence Xamarin.Android.Support.Compat (= 27.0.2). You could notice that the versions are different, a project cannot reference the same reference different version, which cause the version conflict.
To resolve this issue, we need to unify the references of these two different versions. Check the Dependencies of the package Microsoft.Identity.Client 2.2.0-preview, this package have a dependency Xamarin.Android.Support.CustomTabs (>= 27.0.2) and the dependency Xamarin.Android.Support.CustomTabs (>= 27.0.2) also have a dependency Xamarin.Android.Support.Compat (= 27.0.2). So to resolve this issue, we just need to install the dependency Xamarin.Android.Support.CustomTabs (>= 27.0.2.1) at first, which have the dependency is Xamarin.Android.Support.Compat (= 27.0.2.1):
Hope this helps.

Installing Microsoft.Extensions.DependencyInjection in .NET Framework 4.7.1 project

I'm attempting to install the Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.DependencyInjection.Abstractions 2.0.0 nuget packages into a .NET Framework 4.7.1 project (Microsoft.AspNet.OData), however I'm getting the error:
Could not install package 'Microsoft.Extensions.DependencyInjection
2.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.1', but the package does not
contain any assembly references or content files that are compatible
with that framework. For more information, contact the package author.
The dependency for these packages is .NETStandard,Version=v2.0. I understand that .NET Standard isn't .NET Framework, however I thought that .NET Framework 4.6 and greater projects could install .NET Standard projects? If this isn't possible, then are there other equivalent versions of these nuget packages for .NET Framework?
The whole reason that I'm going through this exercise is because many developers are completely blocked by Microsoft.AspNet.OData only supporting DI 1.0, not 2.0. This means that we cannot upgrade our nuget packages in our OData web api, as other packages require DI 2.0 but OData is stuck on 1.0. The rest of our applications are using the latest and greatest, so really it means that our OData web api solution can't leverage ANY of our shared code, and is completely quarantined until this compatibility block is resolved.
Installing Microsoft.Extensions.DependencyInjection in .NET Framework 4.7.1 project
I think the error message is not accurate. When I install the nuget package Microsoft.Extensions.DependencyInjection 2.0.0 to the project (Microsoft.AspNet.OData), I got the following error message:
Unable to resolve dependencies.
'Microsoft.Extensions.DependencyInjection 2.0.0' is not compatible
with 'Microsoft.AspNet.OData 7.0.0-beta2 constraint:
Microsoft.Extensions.DependencyInjection (>= 1.0.0 && < 2.0.0)'.
That is exactly what you said "because many developers are completely blocked by Microsoft.AspNet.OData only supporting DI 1.0, not 2.0."
Check the dependencies of package Microsoft.AspNet.OData, we could know there are strict restrictions for the dependencies Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.DependencyInjection.Abstractions ((>= 1.0.0 && < 2.0.0))
So, this is really a issue that the package Microsoft.AspNet.OData don't support DI 2.0. Many other communities also report this issue on Github, but there is still no any workaround and solution.
My current workaround is:
Create a new project without installing package Microsoft.AspNet.OData.
Install the other dependencies of package Microsoft.AspNet.OData: Microsoft.OData.Core (>= 7.2.0 && < 8.0.0), Microsoft.AspNet.WebApi.Core (>= 5.2.2 && < 5.3.0) and Microsoft.AspNet.WebApi.Client (>= 5.2.2 && < 5.3.0) (The latter two packages should be included in the template by default).
Install the nuget package Microsoft.Extensions.DependencyInjection 2.0.0
Install the nuget package Microsoft.AspNet.OData with option -IgnoreDependencies in the Package Manager Console:
update-package Microsoft.AspNet.OData -IgnoreDependencies -IncludePrerelease
With this workaround, we could use Microsoft.AspNet.OData and DI 2.0, but I could fully confirm whether breaking the dependency limition will cause any problem for the Microsoft.AspNet.OData package. Simple tests are not problematic.
Hope this helps.

Xamarin - The "XamlXTask" task failed unexpectedly

I am getting the following error when trying to build my Xamarin apps in Release. The build in Debug works just fine. This has only started happening lately after updating all nuget packages to the latest version of Xamarin, etc.
Error:
The only fix for me was to downgrade Xamarin.Forms and Xamarin.Forms.Maps from version 2.3.4.247 (currently latest version) to version 2.3.4.231. I tried uninstalling and installing the latest version before and that did not work unfortunately. Version downgrade fixed the issue for me.

Unable to add Xamarin Google Play Services

I'm unable to add GCM to my Xamarin app. This is the output from the package console:
Adding Xamarin.GooglePlayServices.Gcm...
Attempting to resolve dependency 'Xamarin.GooglePlayServices.Base (= 29.0.0.1)'.
Attempting to resolve dependency 'Xamarin.GooglePlayServices.Basement (= 29.0.0.1)'.
Attempting to resolve dependency 'Xamarin.Android.Support.v4 (≥ 23.1.1.1)'.
Attempting to resolve dependency 'Xamarin.GooglePlayServices.Measurement (= 29.0.0.1)'.
Updating 'Xamarin.Android.Support.v4 23.0.1.3' to 'Xamarin.Android.Support.v4 23.3.0' failed. Unable to find a version of 'Xamarin.Forms' that is compatible with 'Xamarin.Android.Support.v4 23.3.0'.
For this version you must install an earlier version of Xamarin.GooglePlayServices.Gcm. I had no problems with 27.0.0.
If you need the newest version, you could do this:
uninstall xamarin.forms nuget package
update all android packages to 23.3.0
install Xamarin.GooglePlayServices.Gcm
search for xamarin.forms and set in options ignore dependencies
install newest version
Of course you must be aware of problems, since this is not recommended with good reasons.
You need to Update your Xamarin.Forms package. Open Packages (Dropdown) in Solutions pane and Right-Click on Xamarin.Forms and click on Update
If you are using PCL, you can find this package in the PCL (Xamarin.Forms) project.
If you are using Shared Asset Project, you will find this package in both Xamarin.Android and Xamarin.iOS project.
You have to update Android SDK Platform-tools to revision 26.0.2 (or equivalent).
Open Android SDK Manager, check update, and select
"Update avaiable rev.26.0.2" and install it.

How to prevent Nuget from updating automatically package (minor) versions?

In the VS solution, I have as dependencies (in the packages.config file)
a package A, version 2.0.0 which has dependency on package B version >= 5.0.0.0. The latest version of A is 2.1.0 and has the same dependencies as in 2.0.0
a package B, version 10.0.0.0. The latest version is 10.0.5.2
I want to update the package A to 2.1.0 so I tried the command
update-package A
in 'package manager console'. But strangely, Nuget updates also the package B to 10.0.5.2.
Someone told me that by default, Nuget will update to the 'bug fix' version, but I haven't found the link about that.
Does anyone know how to tell Nuget to not update other packages automatically ?
For info, I'm using Nuget 2.5, so according to http://docs.nuget.org/docs/reference/versioning, the dependencies are no longer updated during package installation
Thanks.
As far as I'm aware, this cannot be done, and is the main reason we created the ProGet Client Tools.
You might be able to get away with specifying the explicit version by surrounding it in brackets (e.g. [10.0.0.0]) in the packages.config file but that still seemed to grab the bug fix version when I tried it - though I haven't tested it on the latest version yet.
For reference, the NuGet dependency version selection algorithm is described in detail here: http://blog.davidebbo.com/2011/01/nuget-versioning-part-2-core-algorithm.html

Resources