Xamarin.Android: Package XX is not compatible with monoandroid81 (MonoAndroid,Version=v8.1)

I encounter a stranger behavior with a Xamarin.Android project in Visual Studio on Windows.

I've created a new Android blank project, and I try ton install the NuGet package "AForge" (a mathematics library), but I get the following error message:

Package AForge 2.2.5 is not compatible with monoandroid81
(MonoAndroid,Version=v8.1).

I've already tried to re create several projects, after having relaunched Visual Studio and the computer, but the problem is still the same.

However, if I do the same thing on Mac, through Visual Studio for Mac, I don't encounter the same problem: the package is well installed.

In add, I can see in the package.config file, that the package il well related to monodroid81:

<?xml version="1.0" encoding="utf-8"?>
<packages>
    <package id="AForge" version="2.2.5" targetFramework="monoandroid81" />
</packages>

Would you have any explanation about this issue?

Posts

  • mattwardmattward GBMember Xamurai
    edited June 18

    The problem will be a different version of NuGet. I believe that in more recent versions of NuGet if a NuGet package has a lib directory with assemblies, but does not specify the target framework, then it defaults to assuming the assemblies are for .NET Framework. With older versions of NuGet, such as that in Visual Studio for Mac, this restriction is not applied so it allows the assemblies to be installed into any project type, even if this is not supported by the assemblies.

    The AForge NuGet package contains:

    • lib/AForge.dll
    • lib/AForge.xml
  • Pierre-ChristopheDusPierre-ChristopheDus FRUniversity ✭✭✭

    Hi @mattward , thanks for your feedback.
    So what does that mean for AForge package? Is normal that I can't install it in Visual Studio on Windows?

  • mattwardmattward GBMember Xamurai

    I just think the NuGet team have made a change which prevents you from installing the AForge NuGet package. I suspect older versions of Visual Studio used to work. The Visual Studio on Windows behaviour with more recent NuGet versions is likely to be correct but is a breaking change.

    Unfortunately that breaks the use of AForge on Windows. So you could try contacting the author of the AForge NuGet package, otherwise you are left with downloaded it outside of NuGet, unzipping it, and directly referencing the assembly.

  • Pierre-ChristopheDusPierre-ChristopheDus FRUniversity ✭✭✭

    Hi @mattward, thanks again.
    I've added the .dll and it seems to work like this. In a second time, I will see if I can fix it through a proper way.

  • Pierre-ChristopheDusPierre-ChristopheDus FRUniversity ✭✭✭

    Hi @mattward, I encoutner a new issue about the same .dll.
    As I explained, I've added the dll contained in AForge.
    On my desktop, the build works well.
    However, I get an issue when I try to build through AppCenter:

    CoreCompile:
    /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/mono/4.5/csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE;XAMARIN_ANDROID_v1_0;MOBILE;ANDROID;ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4;ANDROID_5;ANDROID_6;ANDROID_7;ANDROID_8;ANDROID_9;ANDROID_10;ANDROID_11;ANDROID_12;ANDROID_13;ANDROID_14;ANDROID_15;ANDROID_16;ANDROID_17;ANDROID_18;ANDROID_19;ANDROID_20;ANDROID_21;ANDROID_22;ANDROID_23;ANDROID_24;ANDROID_25;ANDROID_26;ANDROID_27 /reference:/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/Java.Interop.dll /reference:/Users/vsts/.nuget/packages/microsoft.appcenter.analytics/1.7.0/lib/MonoAndroid403/Microsoft.AppCenter.Analytics.Android.Bindings.dll /reference:/Users/vsts/.nuget/packages/microsoft.appcenter.analytics/1.7.0/lib/MonoAndroid403/Microsoft.AppCenter.Analytics.dll /reference:/Users/vsts/.nuget/packages/... Services/AudioService.cs(8,7): error CS0246: The type or namespace name 'AForge' could not be found (are you missing a using directive or an assembly reference?) [/Users/vsts/agent/2.136.1/work/1/s/XxxApp/XxxApp.csproj] Done Building Project "/Users/vsts/agent/2.136.1/work/1/s/XxxApp/XxxApp.csproj" (PackageForAndroid target(s)) -- FAILED

    Would you have an explanation?

  • mattwardmattward GBMember Xamurai

    Not really. AForge.dll is not being passed to csc as a reference. Does the project have a Reference element to AForge.dll? When AppCenter checks out the project how will it get the AForge.dll? Is it included in your source control repository or is AForge in your packages.config file?

  • Pierre-ChristopheDusPierre-ChristopheDus FRUniversity ✭✭✭

    I've added AForge.dll as a reference. But I've worked on Visual Studio 2017 for Windows, and the comportment is not the same on Visual Studio for Mac.

    When I reopen the project on Mac, the reference is marked as error with this message:

    Assembly not found for framework Xamarin.Android v8.1 Support

    So I don't know if there is a solution allowing me to use this dll in my project...

  • mattwardmattward GBMember Xamurai

    Does the AForge.dll file exist in the location as specified by the Reference?

  • Pierre-ChristopheDusPierre-ChristopheDus FRUniversity ✭✭✭

    On Windows yes: I've imported the dll handly for another project in my Xamarin.Android project.
    But on Mac it seems that the dll is not "recognized".

  • Pierre-ChristopheDusPierre-ChristopheDus FRUniversity ✭✭✭

    I finally managed to fix my issue by copying the dll at the root of my project, before to adding it as reference.

Sign In or Register to comment.