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..
Any thoughts on how to fix this??
I'm running Visual Studio Mac 8.4.8 (build 2). Android target framework is 10.0 (Q).
Thanks.
Answers
According to your description, you mean that you have this issue after you updated all the packages and updated your project to AndroidX and your project have no issue before?
Could you please post the full log here?
I have exactly the same problem. The log states this:
/path/to/project/packages/Xamarin.AndroidX.Migration.1.0.0/build/monoandroid90/Xamarin.AndroidX.Migration.targets(131,9): error : Could not find 1 Android X assemblies, make sure to install the following NuGet packages: /path/to/project/packages/Xamarin.AndroidX.Migration.1.0.0/build/monoandroid90/Xamarin.AndroidX.Migration.targets(131,9): error : - Xamarin.AndroidX.AppCompat.Resources /path/to/project/packages/Xamarin.AndroidX.Migration.1.0.0/build/monoandroid90/Xamarin.AndroidX.Migration.targets(131,9): error : You can also copy-and-paste the following snippet into your .csproj file: /path/to/project/packages/Xamarin.AndroidX.Migration.1.0.0/build/monoandroid90/Xamarin.AndroidX.Migration.targets(131,9): error : <PackageReference Include="Xamarin.AndroidX.AppCompat.Resources" Version="1.1.0" /> Done building target "_AndroidXValidateInstalledPackages" in project "Project.Droid.csproj" -- FAILED.
However everything is up to date in my Nuget packages and I naturally have
Xamarin.AndroidX.AppCompat.Resources
(v.1.1.0)hi here is my full build log
And here's mine: https://gist.github.com/xperseguers/f34adf9fd74967a732375a4a66886bd5
hello any ideas anyone? pls help....
I had the same issue and i did this to fix it:
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 inbin/
andobj/
and the wholepackages/
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:Looks like something must have been totally forgotten when it comes to macOS devs.
FYI, those 2 commits on my project still don't help with that problem:
Since we couldn't reproduce this question ,could you please post a basic demo so that we can test on our side?
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.
@XavierPerseguers If you add manually all packages in your .csprog as package reference and remove package.config?
Like that
OK, so if this helps, my command to manually convert those references:
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 ofpackages.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 withRemoved that line:
Does not help.
Then removed every
<Import Project
lines like that at the end of the.csproj
: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.
**Please install the missing libraries **
AndroidX.Migration.targets(9,9): Error: Could not find 18 Android X assemblies, make sure to install the following NuGet
packages:
** - Xamarin.AndroidX.Browser
- Xamarin.Google.Android.Material
- Xamarin.AndroidX.Legacy.Support.V4**
You can also copy-and-paste the following snippet into your .csproj file:
**
**