Forum Xamarin.Android

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..

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

  • jezhjezh Member, Xamarin Team Xamurai

    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?

  • XavierPerseguersXavierPerseguers CHMember ✭✭✭

    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)

  • Steve1000Steve1000 Member ✭✭

    hi here is my full build log

    Building MyProject.Droid (Debug)
    Build started 11/03/2020 11:11:17.
    __________________________________________________
    Project "/Path/ToProject/Projects/MyProject/MyProject/MyProject.csproj" (Build target(s)):
    
    Target ResolveAssemblyReferences:
        A TargetFramework profile exclusion list will be generated.
        Consider app.config remapping of assembly "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" from Version "6.0.0.0" [] to Version "12.0.0.0" [/Path/ToProject/Projects/MyProject/packages/Newtonsoft.Json.12.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll] to solve conflict and get rid of warning.
        Consider app.config remapping of assembly "Validation, Culture=neutral, PublicKeyToken=2fc06f0d701809a7" from Version "2.2.0.0" [] to Version "2.4.0.0" [/Path/ToProject/Projects/MyProject/packages/Validation.2.4.22/lib/portable-net45+win8+wp8+wpa81/Validation.dll] to solve conflict and get rid of warning.
        Consider app.config remapping of assembly "XLabs.Serialization, Culture=neutral, PublicKeyToken=d65109b36e5040e4" from Version "2.0.5782.12218" [] to Version "2.0.5782.15703" [/Path/ToProject/Projects/MyProject/packages/XLabs.Serialization.2.0.5782/lib/portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1/XLabs.Serialization.dll] to solve conflict and get rid of warning.
        Consider app.config remapping of assembly "System.Numerics.Vectors, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.1.3.0" [] to Version "4.1.4.0" [/Path/ToProject/Projects/MyProject/packages/System.Numerics.Vectors.4.5.0/lib/portable-net45+win8+wp8+wpa81/System.Numerics.Vectors.dll] to solve conflict and get rid of warning.
        /Library/Frameworks/Mono.framework/Versions/6.6.0/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2126,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /><bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="Validation" culture="neutral" publicKeyToken="2fc06f0d701809a7" /><bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="XLabs.Serialization" culture="neutral" publicKeyToken="d65109b36e5040e4" /><bindingRedirect oldVersion="0.0.0.0-2.0.5782.15703" newVersion="2.0.5782.15703" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Numerics.Vectors" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" /></dependentAssembly></assemblyBinding>
    Done building target "ResolveAssemblyReferences" in project "MyProject.csproj".
    Target GenerateTargetFrameworkMonikerAttribute:
      Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
    Target XamlG:
      Skipping target "XamlG" because all output files are up-to-date with respect to the input files.
    Target CssG:
      Skipping target "CssG" because it has no outputs.
    Target CssG:
      Skipping target "CssG" because it has no outputs.
    Target CoreCompile:
      Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
    Target XamlC:
      Skipping target "XamlC" because all output files are up-to-date with respect to the input files.
    Target _CopyFilesMarkedCopyLocal:
        Touching "/Path/ToProject/Projects/MyProject/MyProject/obj/Debug/MyProject.csproj.CopyComplete".
    Target CopyFilesToOutputDirectory:
        MyProject -> /Path/ToProject/Projects/MyProject/MyProject/bin/Debug/MyProject.dll
    
    Done building project "MyProject.csproj".
    __________________________________________________
    Project "/Path/ToProject/Projects/MyProject/Droid/MyProject.Droid.csproj" (Build target(s)):
    
    Target _CleanIntermediateIfNuGetsChange:
      Skipping target "_CleanIntermediateIfNuGetsChange" because all output files are up-to-date with respect to the input files.
    Target _ResolveSdks:
        /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(840,2): warning XA5300: Not a valid JDK directory: ``; via locator: monodroid-config.xml
        Found Java SDK version 1.8.0.
        Found Java SDK version 1.8.0.
    Done building target "_ResolveSdks" in project "MyProject.Droid.csproj".
    Target _ValidateAndroidPackageProperties:
          PackageName: com.MyCo.MyProject
        /Path/ToProject/Projects/MyProject/Droid/Properties/AndroidManifest.xml : warning XA4216: AndroidManifest.xml //uses-sdk/@android:minSdkVersion '15' is less than API-16, this configuration is not supported.
    Done building target "_ValidateAndroidPackageProperties" in project "MyProject.Droid.csproj".
    Target _GetProjectReferenceTargetFrameworkProperties:
        __________________________________________________
        Project "/Path/ToProject/Projects/MyProject/Droid/MyProject.Droid.csproj" is building "/Path/ToProject/Projects/MyProject/MyProject/MyProject.csproj" (GetTargetFrameworks target(s)):
    
    Target ResolveProjectReferences:
        __________________________________________________
        Project "/Path/ToProject/Projects/MyProject/Droid/MyProject.Droid.csproj" is building "/Path/ToProject/Projects/MyProject/MyProject/MyProject.csproj" (GetTargetPath target(s)):
    
        Target BclBuildValidateNugetPackageReferences:
            /Path/ToProject/Projects/MyProject/packages/Microsoft.Bcl.Build.1.0.21/build/Microsoft.Bcl.Build.targets(243,5): warning : All projects referencing MyProject.csproj must install nuget package Microsoft.Bcl.Build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317569.
        Done building target "BclBuildValidateNugetPackageReferences" in project "MyProject.csproj".
    
        Done building project "MyProject.csproj".
        __________________________________________________
        Project "/Path/ToProject/Projects/MyProject/Droid/MyProject.Droid.csproj" is building "/Path/ToProject/Projects/MyProject/MyProject/MyProject.csproj" (GetNativeManifest target(s)):
    
    Target _AndroidXValidateInstalledPackages:
        /Path/ToProject/Projects/MyProject/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/ToProject/Projects/MyProject/packages/Xamarin.AndroidX.Migration.1.0.0/build/monoandroid90/Xamarin.AndroidX.Migration.targets(131,9): error :  - Xamarin.AndroidX.AppCompat.Resources
        /Path/ToProject/Projects/MyProject/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/ToProject/Projects/MyProject/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 "MyProject.Droid.csproj" -- FAILED.
    
    Done building project "MyProject.Droid.csproj" -- FAILED.
    
    Build FAILED.
    
    /Library/Frameworks/Mono.framework/Versions/6.6.0/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2126,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /><bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="Validation" culture="neutral" publicKeyToken="2fc06f0d701809a7" /><bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="XLabs.Serialization" culture="neutral" publicKeyToken="d65109b36e5040e4" /><bindingRedirect oldVersion="0.0.0.0-2.0.5782.15703" newVersion="2.0.5782.15703" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Numerics.Vectors" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" /></dependentAssembly></assemblyBinding>
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(840,2): warning XA5300: Not a valid JDK directory: ``; via locator: monodroid-config.xml
    /Path/ToProject/Projects/MyProject/Droid/Properties/AndroidManifest.xml : warning XA4216: AndroidManifest.xml //uses-sdk/@android:minSdkVersion '15' is less than API-16, this configuration is not supported.
    /Path/ToProject/Projects/MyProject/packages/Microsoft.Bcl.Build.1.0.21/build/Microsoft.Bcl.Build.targets(243,5): warning : All projects referencing MyProject.csproj must install nuget package Microsoft.Bcl.Build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317569.
    /Path/ToProject/Projects/MyProject/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/ToProject/Projects/MyProject/packages/Xamarin.AndroidX.Migration.1.0.0/build/monoandroid90/Xamarin.AndroidX.Migration.targets(131,9): error :  - Xamarin.AndroidX.AppCompat.Resources
    /Path/ToProject/Projects/MyProject/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/ToProject/Projects/MyProject/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" />
        4 Warning(s)
        1 Error(s)
    
    Time Elapsed 00:00:01.38
    
    ========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    
    Build: 1 error, 4 warnings
    
  • Steve1000Steve1000 Member ✭✭

    hello any ideas anyone? pls help....

  • ExoskeletorExoskeletor Member ✭✭
    edited March 14

    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

  • XavierPerseguersXavierPerseguers CHMember ✭✭✭

    @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.

  • ExoskeletorExoskeletor Member ✭✭

    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

  • XavierPerseguersXavierPerseguers CHMember ✭✭✭

    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:

    <U+FEFF><?xml version="1.0" encoding="utf-8"?>
    <packages>
      <package id="Xamarin.AndroidX.Activity" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Annotation" version="1.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Arch.Core.Common" version="2.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Arch.Core.Runtime" version="2.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.AsyncLayoutInflater" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.CardView" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Collection" version="1.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.CoordinatorLayout" version="1.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Core" version="1.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.CursorAdapter" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.CustomView" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.DocumentFile" version="1.0.1" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.DrawerLayout" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Interpolator" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Lifecycle.Common" version="2.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Lifecycle.LiveData" version="2.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Lifecycle.LiveData.Core" version="2.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Lifecycle.Runtime" version="2.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Lifecycle.ViewModel" version="2.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Loader" version="1.1.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.LocalBroadcastManager" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Migration" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.MultiDex" version="2.0.1" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.Print" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.SavedState" version="1.0.0" targetFramework="monoandroid10.0" />
      <package id="Xamarin.AndroidX.VersionedParcelable" version="1.1.0" targetFramework="monoandroid10.0" />
    </packages>
    

    Looks like something must have been totally forgotten when it comes to macOS devs.

  • XavierPerseguersXavierPerseguers CHMember ✭✭✭

    FYI, those 2 commits on my project still don't help with that problem:

    ead42875 [TASK] Upgrade Xamarin.Forms to v4.5.0.396
    b500a262 [TASK] Upgrade Microsoft.Build.Framework to v16.5.0
    
  • jezhjezh Member, Xamarin Team Xamurai

    Since we couldn't reproduce this question ,could you please post a basic demo so that we can test on our side?

  • EspectrosEspectros Member ✭✭

    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

  • XavierPerseguersXavierPerseguers CHMember ✭✭✭

    @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.

  • ExoskeletorExoskeletor Member ✭✭
    edited March 31

    @XavierPerseguers If you add manually all packages in your .csprog as package reference and remove package.config?
    Like that

        <ItemGroup>
            <PackageReference Include="FourTwenty.Xamarin.ColorPickerView">
              <Version>1.0.0.31-pre</Version>
            </PackageReference>
         </ItemGroup>
    
  • XavierPerseguersXavierPerseguers CHMember ✭✭✭

    OK, so if this helps, my command to manually convert those references:

    $ sed -E 's/^  <package id="([^"]+)" version="([^"]+)".*$/<PackageReference Include="\1"><Version>\2<\/Version><\/PackageReference>/' packages.config | pbcopy
    

    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

    Error XF001: Xamarin.Forms targets have been imported multiple times. Please check your project file and remove the duplicate import(s). (XF001)
    

    Removed that line:

        <PackageReference Include="Xamarin.Forms"><Version>4.5.0.495</Version></PackageReference>
    

    Does not help.

    Then removed every <Import Project lines like that at the end of the .csproj:

    <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
    

    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.

  • ExoskeletorExoskeletor Member ✭✭
    For a moment i was scared that my suggestion destroy your project but in the end i see something good came up :)
  • ExoskeletorExoskeletor Member ✭✭
    If xamarin.forms is missing from packages and the dlls are gone after cleaning then were vs finds it again? It should be somewhere in a corner :)
Sign In or Register to comment.