Quick Links

Could not find 1 Android X assemblies.... But its already installed.

Hi,
I'm trying to build my xamarin forms app for android - i've updated all the packages and added the AndroidX ones to the Droid project, however i keep getting an error messages:

Error: Could not find 1 Android X assemblies, make sure to install the following NuGet packages:
- Xamarin.AndroidX.AppCompat.Resources
You can also copy-and-paste the following snippet into your .csproj file:
(MyApp.Droid)

I've already installed Xamarin.AndroidX.AppCompat.Resources to the android project.. i've also removed the package and then re-installed it to the project, cleaned the project, deleted bin / obj folders, restarted visual studio but im still getting the same error message..

1)remove all androidx packages
2)first if you have done this suggestion "You can also copy-and-paste the following snippet into your .csproj file:" undo it and then do this if you havent done it already https://docs.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference
3)After that install the androidx migration and start doing what it is suggesting one by one. if you get a message that it is not installed at this point you can add the snippet with the package-reference, i added the snippet for all the AndroidX packages

In general in me the problem was caused by having packages-config and package-reference together

@Exoskeletor Are you using Visual Studio for Mac? I just cannot find the option to migrate from packages.config to Package Reference. No option when doing the right click either on the References/Packages or packages.config. These instructions don't help either: https://github.com/NuGet/docs.microsoft.com-nuget/issues/905 they seem to be related to Visual Studio for Windows.

No sorry i'm running Visual Studio for Windows.
if you have packages that are using packages.config try to remove them and install them as package reference although if you have a lot of them maybe its better to wait for an auto migrate feature

I tried to remove the whole packages.config, trashed everything in bin/ and obj/ and the whole packages/ directory, then naturally not more packages loaded, it doesn't compile.

I chose to Migrate to AndroidX with the context menu, just as before doing this, nothing really happens (absolute no change in the project files except the removal of the BOM in the Android project file). Adding Xamarin.Forms again adds a few AndroidX packages but these are not added as reference, it recreates a packages.config file:

I had this problem in a Xamarin Android app when trying to migrate from Android.Support... to AndroidX.
Microsoft Docs doesn't explain (or at least I havent seen) that you must migrate from packages.config to PackageReference first.
Here's what I did
(At first I tried the AndroidX migration by using packages.config then moving from packages.config to PackageReference in that order... Caused this issue you mention)
1| Revert back everything and keep using Android support and packages.config.
2| Now, you want to right click in 'References' inside your project and then click 'Migrate to PackageReference'
3| Once this is done, be sure that your project works correctly.
4| Now download AndroidX.Migration package (will help you by showing missing Nuget AndroidX packages and such)
5| Install the packages that AndroidX.Migration shows (it'll show errors telling you the missing packages) BE CAREFUL, don't unistall the Android.Support.. packages yet, as they are neccesary while youre migrating.
6| Now it shouldn't show this error of Missing 1 android assembly.
(if still does please copy and paste the message you were prompted) into the csproj file after deloading your project
and reload the project back)
7| Now compile, it should work.
8| Replace all the Android.Support... dependant code in your source code
9| After all of this is done, remove all the Android.Support packages

I hope this is some of use for you and people trying to solve these errors

@Espectros If I'm right after the discussion with @Exoskeletor, what you describe is valid for Visual Studio running on Windows. I'm running macOS (don't know about @Steve1000) and as far as I checked, there is absolutely no way to find a menu entry "Migrate to PackageReference" when running VS on macOS.

Then took my .csproj and pasted everything within a <ItemGroup> (then removed xml start marker and <packages> tag which I did not bother to filter out via command line), right before the few references and removed the inclusion of packages.config which I then deleted from disk.

[save point]

After opening project again, it fails since Xamarin.Forms is imported multiple times. I closed VS and edited project again to remove the whole <Reference> blocks.

Deleted directory packages and opened project again, everything is restored but build still fails with

Not a good idea. Lots more problems, so reverted to [save point] and removed every line related to "xamarin.forms" instead.

Now Xamarin.Forms is totally missing from packages but VS is able of compiling successfully my project, even when cleaning first! Crazy!!! Changed something in a shared XAML to be sure, deploying and running without any problem to an emulator.