Essentials: [Android] NuGet Support Library Dependency Issues - Cause Installation Issues

Created on 16 May 2018  路  27Comments  路  Source: xamarin/Essentials

Bug report best practices: Submitting Issues

trying to install Xamarin.Essentials and it is failing for the Android project.

Steps to Reproduce

  1. Via Package Manager
  2. Or command Line (install-package xamarin.essentials -prerelease)

Expected Behavior

Should install

Actual Behavior

Fails with..
Severity Code Description Project File Line Suppression State
Error NU1107 Version conflict detected for Xamarin.Android.Support.Compat. Reference the package directly from the project to resolve this issue.
Classtars.Android -> Xamarin.Android.Support.v7.MediaRouter 27.0.2 -> Xamarin.Android.Support.v7.Palette 27.0.2 -> Xamarin.Android.Support.Compat (= 27.0.2)
Classtars.Android -> AzureServiceProxies -> Xamarin.Essentials 0.6.0-preview -> Xamarin.Android.Support.CustomTabs 25.4.0.2 -> Xamarin.Android.Support.Compat (= 25.4.0.2).

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:

    • iOS: 11.3 - Android: API Level 19 - API Level 27
    • UWP:
  • Android Support Library Version:
  • Nuget Packages:

Screenshots

Reproduction Link

question

All 27 comments

I think you might be able to get around this by first installing "Xamarin.Android.Support.CustomTabs" v27.0.2 into the "AzureServiceProxies" project.

I think this is a known issue with the support libraries, but I am away from me PC right now. @redth will know for sure.

@mattleibow Yes it works like that.

@mattleibow. If I add "Xamarin.Android.Support.CustomTabs" to the "AzureServiceProxies", will that project still be able to be linked with UWP and IoS projects? It is currently a common netstandard utility project.
Thanks

Is that a multitargeting project? For some reason it is pulling in Android downloads.

The error states that it doesn't know which version of Xamarin.Android.Support.Compat you want installed, since one dependency wants 25.4.0.2 and one wants 27.0.2. You can work around this error by picking the explicit version you want and putting that into your .csproj as a

You may have to repeat this step for other packages as well.

It doesn't hurt anything for instance, to specify:

<PackageReference Include="Xamarin.Android.Support.Compat" Version="27.0.2" />
<PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="27.0.2" />
<!-- etc. -->

@Redth - is it possible to re-open this? Although there is a workaround, for a new developer they should just be able to go File->New Xamarin Forms app and add this nuget without having to implement some trickery.

@jimbobbennett

I'm not entirely sure how we would make this any better. We can depend on the latest version of support ourselves which will help I guess with the latest templates shipping in visual studio however users with other deps of a different version will still hit this.

Unfortunately packagreference resolves differently than packages.config does and this problem is fairly common now (and not with just android support libs)

@jamesmontemagno maybe we should at least bump to using 27.0.2 for support. It _will_ help the new project use case.

Yes, sounds good to me.

In 15.8 it will just be included so wont be an issue for file-> new..

Concern is knowing what package people have today and if they will able to install. You fix for one and break for another.

I think doing.... Android71 -> 25.4.0.2 and Android81->27.0.2 is the right way to do it to be honest.

@jamesmontemagno looking forward for this fix, can't really use this lib if I'm using all the updated android.support libraries

It isn't a fix with us, it is a nuget issue and you will run into this with other packages.

You just need to add:

<PackageReference Include="Xamarin.Android.Support.Compat" Version="27.0.2" />
<PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="27.0.2" />

in your android project or manually install those first, it is that easy

Thanks all for your help. I added the two references and the Xamarin.Essentials installed in all my projects.
Will I need to uninstall those refences with the next release of Xamarin.Essentials?

Thanks again.

They usually get automatically added, but nuget itself has some issues with dependency numbers here. In the next versions you will NOT need to take any action and should work just the same.

@jamesmontemagno I've bumped in this issue and solved with the workaround. So far, so good.
Even if it's a more general issue related to NuGet, maybe it should be noted in the documentation for Xamarin.Essentials as almost everyone will have the same problem.

We have a new package coming out this week to fix this up and will be updating the docs :)

We're also going to move to try and be in sync more with Xamarin.Forms in the version of Android support we use. Generally we will be always recommending the latest version of the support libraries.

still getting this annoyance with the latest preview XF 3.2.0.637442-pre1:

Error NU1107 Version conflict detected for Xamarin.Android.Support.Compat. Reference the package directly from the project to resolve this issue.
Miele.Forms.Android -> Miele.Forms -> Miele.Application.Base -> Xamarin.Essentials 0.8.0-preview -> Xamarin.Android.Support.CustomTabs 27.0.2.1 -> Xamarin.Android.Support.Compat (= 27.0.2.1)
Miele.Forms.Android -> Miele.Forms -> Xamarin.Forms 3.2.0.637442-pre1 -> Xamarin.Android.Support.v4 27.0.2 -> Xamarin.Android.Support.Compat (= 27.0.2).

it's off by the last digit in the version :(

In 0.8.0 we updated to 27.0.2.1

Please update all of your support versions to this. In your Android csproj you can add these:

<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="27.0.2.1" />

Make sure to bump your other ones too.

hi @jamesmontemagno, unfortunately I am using the

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

in both my android and ios projects so from what I read and understood it automatically takes care of the support libraries references from the .net standard 2.0 project, which works perfectly until I add the Essentials nuget which makes Android uncompilable

See: https://redth.codes/how-to-fix-the-dreaded-version-conflict-nuget-error-in-your-xamarin-android-projects/ @WarBorg They didn't show up on my comment above sorry.

Simply add those two and update the other ones that are in your reference to 27.0.2.1.

<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="27.0.2.1" />

of you can add these manually first with your current version of support.

@jamesmontemagno I have tried your solution.
I have modified android prj adding Compat and CustomTabs references, but I am not able to update other packages

Gravit脿 Codice Descrizione Progetto File Riga Stato eliminazione
Errore Il pacchetto Xamarin.Android.Support.v7.MediaRouter 27.0.2.1 non 猫 compatibile con netstandard2.0 (.NETStandard,Version=v2.0). Il pacchetto Xamarin.Android.Support.v7.MediaRouter 27.0.2.1 supporta: monoandroid81 (MonoAndroid,Version=v8.1) 0

What can I do?

You need to ensure your compile version is set to Android 8.1 (this is compile, not target/min). Then make sure all of your support ar at 27.0.2.1

https://github.com/jamesmontemagno/app-compass/blob/master/MyCompass/MyCompass.Android/MyCompass.Android.csproj

excellent @jamesmontemagno

adding manually these rows

    <PackageReference Include="Xamarin.Forms" Version="3.1.0.583944" />
    <PackageReference Include="Xamarin.Android.Support.Design" Version="27.0.2.1" />
    <PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.2.1" />
    <PackageReference Include="Xamarin.Android.Support.v4" Version="27.0.2.1" />
    <PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="27.0.2.1" />
    <PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="27.0.2.1" />

not I can add Essentials 0.8.0-preview

@jamesmontemagno: is there any particular reason why you suggested to

Simply add those two and update the other ones that are in your reference to 27.0.2.1.

<PackageReference Include="Xamarin.Android.Support.Compat" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="27.0.2.1" />

when, AFAIK, the Xamarin.Android.Support.Compat sholud be the Xamarin.Android.Support.v7.AppCompat one ?

In fact, the code you linked contains those references:

<PackageReference Include="Xamarin.Forms" Version="3.1.0.583944" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="27.0.2.1" />

I think it should be better (for new readers looking for a solution) to add few lines of guidance in the readme of this project, because this is an issue that everybody will hit trying to use it.

You don't have to, but it doesn't hurt anything at all. It should be "Core.Utils" and "CustomTabs"

We also have links to the troubleshooting for android which outlines this.

Was this page helpful?
0 / 5 - 0 ratings