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

使用Microsoft.Intune.Maui.Essentials.android部署应用遇类找不到异常

解决Microsoft.Intune.Maui.Essentials.android部署时的MAMFileProvider类找不到异常

问题详情

部署MAUI Android应用时触发以下异常:

Java.Lang.RuntimeException: 'Unable to get provider com.microsoft.intune.mam.client.support.v4.content.MAMFileProvider: java.lang.ClassNotFoundException: Didn't find class "com.microsoft.intune.mam.client.support.v4.content.MAMFileProvider" on path: DexPathList[[zip file "/data/app/~~uJpDSAeopTW92kLUdUgp1w==/jp.co.cegb.archxtractpush-iXeGEc6Slh13UJIq_1k60Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~uJpDSAeopTW92kLUdUgp1w==/jp.co.cegb.archxtractpush-iXeGEc6Slh13UJIq_1k60Q==/lib/arm64, /data/app/~~uJpDSAeopTW92kLUdUgp1w==/jp.co.cegb.archxtractpush-iXeGEc6Slh13UJIq_1k60Q==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]'

当前Android清单配置:

<provider tools:replace="android:authorities" android:name="com.microsoft.intune.mam.client.support.v4.content.MAMFileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
    <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" tools:replace="android:resource" />
</provider>

环境信息:

  • Microsoft.Intune.Maui.Essentials.android版本:9.5.2-Beta2
  • 操作系统:Windows
  • Visual Studio版本:17.7.4
  • 该问题未在Xamarin Android Intune SDK中出现

解决步骤

1. 替换清单中的MAMFileProvider类路径

MAUI默认使用AndroidX库,原配置中的support.v4类属于旧版Android Support库,Intune MAUI SDK已适配AndroidX,需修改Provider配置:

<provider tools:replace="android:authorities" android:name="com.microsoft.intune.mam.client.androidx.content.MAMFileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
    <meta-data android:name="androidx.core.content.FileProvider.PATH" android:resource="@xml/file_paths" tools:replace="android:resource" />
</provider>

2. 添加R8/ProGuard混淆规则

在MAUI Android项目中创建r8.cfg文件,添加以下规则避免Intune相关类被混淆或移除:

-keep class com.microsoft.intune.mam.** { *; }
-keep class com.microsoft.aad.** { *; }

然后在项目的.csproj文件中添加引用:

<ItemGroup>
  <AndroidR8Cfg Include="r8.cfg" />
</ItemGroup>

3. 清理重建并验证依赖

  • 手动删除项目的bin、obj目录,清除构建缓存
  • 卸载并重新安装Microsoft.Intune.Maui.Essentials NuGet包
  • 重启Visual Studio后重新构建部署

4. 启用MultiDex(可选)

若应用依赖较多,可开启MultiDex解决Dex打包限制:
在Android清单中修改application节点:

<application android:name="androidx.multidex.MultiDexApplication" ...>

同时在.csproj文件中添加:

<AndroidEnableMultiDex>true</AndroidEnableMultiDex>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 01:28:35