Search code examples
xamarinxamarin.formsxamarin.androidrider

Error: Could not find 2 Android X assemblies, make sure to install the following NuGet packages: - Xamarin.AndroidX.MediaRouter


Using Jetbrains Rider, I created a new Xamarin application. Because Rider creates a Xamarin application with an older version (4.4.0.991640), I upgraded Xamarin to the latest version (4.8.0.1687).

However, when I build, I get the following error:

Xamarin.AndroidX.Migration.targets(131, 9): Could not find 2 Android X assemblies, make sure to install the following NuGet packages:
 - Xamarin.AndroidX.MediaRouter
You can also copy-and-paste the following snippet into your .csproj file:
    <PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.1.0.1" />

I followed the instructions by adding the snippet to my .csproj file.

ExampleProject.Android.csproj

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
        <PackageReference Include="Xamarin.Forms" Version="4.8.0.1687" />
        <PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
        <PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.3" />
        <PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.3" />
        <PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.3" />
        <PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.3" />
        
        <!-- Newly added -->
        <PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.1.0.1" />
    </ItemGroup>
</Project>

Then I:

  1. Ran dotnet restore on the solution
  2. Cleaned the solution
  3. Built the solution

However, I'm still getting the error.


Solution

  • I resolved the issue by:

    1. Removing the dependency from the .csproj file
    2. Installing the latest version of Xamarin.AndroidX.MediaRouter (1.2.0) from the Rider NuGet tab

    Xamarin.AndroidX.MediaRouter in Rider NuGet tab

    Note: I had to also install the Xamarin.AndroidX.Palette (1.0.0.5) package to resolve both build errors.