3
votes

I created a Xamarin.Forms app using the project template from Visual Studio 2019. The project created targets Android 8.1 (Oreo).

Since I wish to use the SecureStorage feature of Xamarin.Essentials, I have to set the target framework to Android 9.

When replacing the target framework with newer one, I got an error that says that I need to download all Android packages of the same version.

Current

The problem is that I can't update the packages to v28.0.0.1 after changing the target framework.

Version conflict detected for Xamarin.Android.Support.Compat. 
Install/reference Xamarin.Android.Support.Compat 28.0.0.1 directly to project MyApp.Android to resolve this issue. 
MyApp.Android -> Xamarin.Forms 3.6.0.293080 -> Xamarin.Android.Support.CustomTabs 28.0.0.1 -> Xamarin.Android.Support.Compat (= 28.0.0.1) 
MyApp.Android -> Xamarin.Android.Support.v7.AppCompat 27.0.2.1 ->    Xamarin.Android.Support.Compat (= 27.0.2.1).   
MyApp.Android   C:\Users\User\source\repos\MyApp\MyApp\MyApp.Android\MyApp.Android.csproj`  

I tried but I could not install the package named Xamarin.Android.Support.Compat (version 28.0.0.1). Also, opening the .csproj and manually replacing the version number from 27.0.2.1 to 28.0.0.1 gives me a bunch of errors from a config xml of the MyApp.Android project.


How can I solve this issue? I need to target Android 9 because of the Xamarin.Essentials nuget to work, but I need to update the current Android.Support nugets to 28.0.0.1 before that.

1

1 Answers

1
votes

I did have the same issue and solved it by manually editing my nuget references.

Option 1: If you use packages.config open the file and manually edit the version to the desired value like shown in the example below

<packages>
  <package id="Xamarin.Android.Support.Design" version="28.0.0.1" targetFramework="net46" />
</packages>

Option 2: If you use package references, you need to edit your .csproj file In VS2019 just douple click it in the solution explorer. In an earlier version you need to unload it first or open it a texteditor. Then edit the section to your desire

    <ItemGroup>
      <PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.1" />
    </ItemGroup>

Maybe also a forced update works: https://docs.microsoft.com/en-us/nuget/consume-packages/reinstalling-and-updating-packages