Xamarin.Android:软件包XX与monoandroid81不兼容(MonoAndroid,版本= v8.1) [英] Xamarin.Android: Package XX is not compatible with monoandroid81 (MonoAndroid,Version=v8.1)

查看:721
本文介绍了Xamarin.Android:软件包XX与monoandroid81不兼容(MonoAndroid,版本= v8.1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上的 Visual Studio 中的 Xamarin.Android 项目中遇到了陌生人的行为.

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

我创建了一个新的 Android空白项目,然后尝试安装 NuGet软件包"AForge" (一个数学库),但是出现以下错误讯息:

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:

软件包AForge 2.2.5与monoandroid81不兼容 (MonoAndroid,Version = v8.1).

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

在重新启动Visual Studio和计算机之后,我已经尝试重新创建多个项目,但是问题仍然相同.

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

但是,如果我通过 Visual Studio for Mac Mac 上执行相同的操作,则不会遇到相同的问题:软件包安装正确.

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.

此外,我可以在package.config文件中看到该软件包与monodroid81有很好的关联:

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?

更新:新问题

您好,@ Leo Liu-MSFT,当您遇到新问题时,我会再次与您联系. dll副本在本地可以正常运行,但是在AppCenter上出现错误:

Hi @Leo Liu-MSFT, I come back to you as I encounter an new issue. The dll copy works fine locally, but I get an error on AppCenter:

CoreCompile:
/库/框架/Mono.framework/版本/5.10.1/lib/mono/4.5/csc.exe /noconfig/nowarn:1701,1702/nostdlib +/errorreport:提示/warn:4 /define:DEBUG; TRACE; XAMARIN_ANDROID_v1_0 ; 移动 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 /参考:/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 /参考:/Users/vsts/.nuget/packages/... Services/AudioService.cs(8,7):错误CS0246:类型或名称空间 找不到名称"AForge"(您是否缺少using指令或 组装参考?) [/Users/vsts/agent/2.136.1/work/1/s/XxxApp/XxxApp.csproj]完成 建筑工程 "/Users/vsts/agent/2.136.1/work/1/s/XxxApp/XxxApp.csproj" (PackageForAndroid目标)-失败.

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.

所以我尝试了您的建议,但是在尝试保存程序包时出现错误:

So I tried your suggestion, but I get an error when I try to save the package:

本地文件头已损坏"

a local file header is corrupted'

您还有其他建议吗?

推荐答案

您对此问题有任何解释吗?

Would you have any explanation about this issue?

您可以获取正式文档 此处:

说明:对于PackageReference,程序集位于以下目录的根目录下 没有目标框架特定子文件夹的lib文件夹将被忽略. NuGet寻找与目标框架绰号匹配的子文件夹 (TFM)与该项目的目标框架相对应,并安装 将程序集匹配到项目中.

Description: With PackageReference, assemblies present at the root of lib folder without a target framework specific sub-folder are ignored. NuGet looks for a sub-folder matching the target framework moniker (TFM) corresponding to the project’s target framework and installs the matching assemblies into the project.

在这种情况下,NuGet将考虑将此程序包安装到与monoandroid81不兼容的.NET Framework中.然后,您将看到错误消息"Package AForge 2.2.5与monoandroid81不兼容".

In this case, NuGet will consider installing this package to the .NET Framework, which is not compatible with monoandroid81. Then you will that error "Package AForge 2.2.5 is not compatible with monoandroid81".

要解决此问题,最好的方法是与AForge NuGet软件包的作者联系以更新此软件包,或者您也可以直接将参考dll文件添加到项目中.

To resolve this issue, the best way is contact the author of the AForge NuGet package to update this package, or you can also add reference dll file directly to your project.

此外,如果您仍然想使用nuget来管理此软件包,我想为您提供一种解决此问题的方法:

Besides, if you still want to use nuget to manager this package, I would like provide you a workaround to resolve this issue:

  1. nuget.org 下载此nuget软件包.

  1. Download this nuget package from nuget.org.

复制下载包,用.zip重命名,例如aforge.2.2.5 - Copy.nupkg.zip,然后解压缩.

Copy the download package, rename it with .zip, like aforge.2.2.5 - Copy.nupkg.zip, then unzip it.

使用NuGet包资源管理器打开包aforge.2.2.5.nupkg(从Microsoft商店获取),在lib节点下添加一个新文件夹MonoAndroid81,从复制文件夹中添加现有文件AForge.dll和AForge.xml. aforge.2.2.5 - Copy.nupkg.zip,保存此nuget程序包.

Open the package aforge.2.2.5.nupkg with NuGet Package Explorer(Get it from Microsoft store), add a new folder MonoAndroid81 under the lib node, add exists file AForge.dll and AForge.xml from the copy folder aforge.2.2.5 - Copy.nupkg.zip, save this nuget package.

将此新的创建nuget包添加到nuget本地feed中,然后将此nuget包添加到项目中.添加包之前,请不要忘记删除C:\Users\<UserName>\.nuget\packages\aforge中的nuget包缓存.

Add this new create nuget package to the nuget local feed, then add this nuget package to the project. Do not forget delete the nuget package cache in the C:\Users\<UserName>\.nuget\packages\aforge before you add the package.

希望这会有所帮助.

这篇关于Xamarin.Android:软件包XX与monoandroid81不兼容(MonoAndroid,版本= v8.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆