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

发布MAUI应用时遇Duplicate assemblies encountered错误求助

解决MAUI Android发布时的重复程序集哈希错误

调试MAUI应用到Android设备一切正常,但发布时出现以下错误:

Duplicate 32-bit hash 0x2159891885 encountered for assembly Microsoft.Maui
Duplicate 32-bit hash 0x2159891885 encountered for assembly Microsoft.Maui
Duplicate 32-bit hash 0x2159891885 encountered for assembly Microsoft.Maui
Duplicate 32-bit hash 0x3800979733 encountered for assembly Microsoft.Maui.Controls.Compatibility
Duplicate 32-bit hash 0x3800979733 encountered for assembly Microsoft.Maui.Controls.Compatibility
Duplicate 32-bit hash 0x3800979733 encountered for assembly Microsoft.Maui.Controls.Compatibility
Duplicate 32-bit hash 0x2758225723 encountered for assembly Microsoft.Maui.Controls.Xaml
Duplicate 32-bit hash 0x2758225723 encountered for assembly Microsoft.Maui.Controls.Xaml
Duplicate 32-bit hash 0x2758225723 encountered for assembly Microsoft.Maui.Controls.Xaml
Duplicate 32-bit hash 0x2480646305 encountered for assembly Microsoft.Maui.Controls
Duplicate 32-bit hash 0x2480646305 encountered for assembly Microsoft.Maui.Controls
Duplicate 32-bit hash 0x2480646305 encountered for assembly Microsoft.Maui.Controls
Duplicate 32-bit hash 0x2861189240 encountered for assembly Microsoft.Maui.Essentials
Duplicate 32-bit hash 0x2861189240 encountered for assembly Microsoft.Maui.Essentials
Duplicate 32-bit hash 0x2861189240 encountered for assembly Microsoft.Maui.Essentials
XABLD7009: System.InvalidOperationException: Duplicate assemblies encountered

使用环境:Visual Studio Community 2022 17.5.1,项目依赖Plugin.Maui.Audio和Community Toolkit。

以下是可行的解决步骤:

  • 清理项目与解决方案:右键解决方案选择「清理解决方案」,再右键项目选择「清理」,手动删除项目目录下的bin和obj文件夹,重启Visual Studio后重新尝试发布。
  • 统一NuGet包版本:打开NuGet包管理器,确保所有MAUI核心包(Microsoft.Maui.*)、Plugin.Maui.Audio、Community Toolkit的版本完全一致,避免版本冲突导致重复引用。
  • 调整发布配置:右键Android项目→属性→发布→高级,暂时取消勾选「启用代码收缩(R8)」,同时检查目标架构设置,避免重复架构的引用。
  • 编辑项目文件:打开项目的.csproj文件,移除重复的<PackageReference>节点,在<PropertyGroup>中添加以下配置:
    <AndroidUseAapt2>true</AndroidUseAapt2>
    <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
    
  • 更新Visual Studio:17.5.1版本存在部分MAUI发布的已知问题,升级到最新稳定版可修复兼容性问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 17:17:34