如何修复Xamarin Android:不支持Mono共享单律

发布于 2025-01-28 04:26:55 字数 1839 浏览 3 评论 0原文

当我部署(或存档)我的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相思故 2025-02-04 04:26:55

我们以前遇到过类似的问题,您可以尝试以下方法:

1。在发布模式中,请确保取消选中使用快速部署(仅调试模式);

2.请确保将nuget更新为最新的nuget,旧的nuget有一个问题。3

。如果问题持续下去,您可以尝试以下可进行:

 <AndroidUseAssemblyStore>false</AndroidUseAssemblyStore>

在与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

 <AndroidUseAssemblyStore>false</AndroidUseAssemblyStore>

in the configuration you are using with Xamarin.UITest.

4.try to delete obj and bin folders in your app and try again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文