You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xamarin.Forms项目打包APK时遇System.Numerics.Vectors版本冲突无法解决

解决Xamarin.Forms归档发布时System.Numerics.Vectors版本冲突问题

排查依赖版本冲突

  • 打开NuGet包管理器的「管理解决方案的NuGet程序包」,切换到「已安装」标签,筛选System.Numerics.Vectors,查看所有项目的实际安装版本,确认是否存在隐藏的版本差异。
  • 检查解决方案根目录的packages.config(旧格式项目)或各项目的.csproj文件,搜索System.Numerics.Vectors,排查是否有版本不一致的引用。

强制统一依赖版本

在解决方案根目录新建或编辑Directory.Build.props文件,添加以下配置,强制所有项目使用指定版本的System.Numerics.Vectors:

<Project>
  <PropertyGroup>
    <NuGetPackageVersion>4.5.0</NuGetPackageVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" PrivateAssets="All" />
  </ItemGroup>
</Project>

清理重建项目

  • 右键解决方案,选择「清理解决方案」。
  • 删除所有项目下的bin和obj目录。
  • 右键Android项目执行「重建项目」,之后再尝试归档操作。

调整Android项目发布构建配置

在MyPorject.Android的.csproj文件中添加以下配置,确保发布构建时自动处理依赖版本冲突:

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

排查间接依赖

使用NuGet命令行工具执行以下命令,查看完整依赖树,定位引入不同版本System.Numerics.Vectors的间接依赖包:

dotnet list package --include-transitive

找到冲突包后,要么将其更新到兼容4.5.0版本的版本,要么调整System.Numerics.Vectors版本至与依赖包匹配的版本。


内容的提问来源于stack exchange,提问作者Drake

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 17:32:52