如何修复Xamarin Android:不支持Mono共享单律
当我部署(或存档)我的Xamarin.android应用程序并尝试在UI测试中使用.APK文件时,我会遇到此错误。我的配置正是发布构建的应该是如何的。 (请阅读到最后)
System.Exception : Mono Shared Runtime is not supported. This can be resolved by changing the project configuration or using a Release build.
stack跟踪
ApkFile.EnsureNoSharedRuntime()
AndroidAppInitializer.PrepareApkFiles(IAndroidAppConfiguration appConfiguration, ArtifactFolder artifactFolder)
AndroidApp.ctor(IAndroidAppConfiguration appConfiguration, IExecutor executor)
AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
AppInitializer.StartApp(Platform platform)
Tests.BeforeEachTest()
AndroidManifest.xml
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
<BundleAssemblies>false</BundleAssemblies>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidSupportedAbis />
</PropertyGroup>
这是荒谬>荒谬的我已经看到有关此问题的问题,直到五年前,还有很多未得到答复。如果有人知道解决这个问题,请帮助我和其他所有遇到这个问题的人。
我从字面上创建了一个使用VS2022甚至发行配置的全新项目。此错误仍然显示在模拟和物理设备上。
更新:在使用Azure DevOps构建和签名的项目时,.APK文件在Uitest上工作。我坚信这是一个视觉工作室APK部署问题。
When I deploy (or archive) my Xamarin.Android application and attempt to use the .APK file in a UI test I am met with this error. My configuration is exactly how it should be for a release build.
(PLEASE READ TO THE END)
System.Exception : Mono Shared Runtime is not supported. This can be resolved by changing the project configuration or using a Release build.
Stack Trace
ApkFile.EnsureNoSharedRuntime()
AndroidAppInitializer.PrepareApkFiles(IAndroidAppConfiguration appConfiguration, ArtifactFolder artifactFolder)
AndroidApp.ctor(IAndroidAppConfiguration appConfiguration, IExecutor executor)
AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
AppInitializer.StartApp(Platform platform)
Tests.BeforeEachTest()
AndroidManifest.xml
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
<BundleAssemblies>false</BundleAssemblies>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidSupportedAbis />
</PropertyGroup>
This is ridiculous I have seen questions about this going up to FIVE years back and many unanswered. If someone knows a fix to this please let's help me and everyone else having this issue.
I literally created a brand new project with VS2022 and even on the release config. this error still shows on both emulated and physical devices.
Update: When the project is built and signed with Azure Devops the .APK file works on UITest. I am convinced this is a Visual Studio APK deployment problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们以前遇到过类似的问题,您可以尝试以下方法:
1。在发布模式中,请确保取消选中
使用快速部署(仅调试模式)
;2.请确保将nuget更新为最新的nuget,旧的nuget有一个问题。3
。如果问题持续下去,您可以尝试以下可进行:
在与xamarin.uitest一起使用的配置中设置。
4.尝试删除应用程序中的OBJ和BIN文件夹,然后重试。
We've had similar problems before, you can try the following methods:
1.in release mode,please make sure you uncheck
use Fast Deployment(debug mode only)
;2.make sure update your nuget to the latest one,the old Nuget had this issue;
3.If the problem persists,you can try the following workaround: set
in the configuration you are using with Xamarin.UITest.
4.try to delete obj and bin folders in your app and try again.