當我部署(或存檔)我的 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.
堆疊跟蹤
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 上運行。我確信這是一個 Visual Studio APK 部署問題。
uj5u.com熱心網友回復:
我們之前也遇到過類似的問題,您可以嘗試以下方法:
1.在發布模式下,請務必取消勾選use Fast Deployment(debug mode only);
2.確保更新你的nuget到最新的,舊的Nuget有這個問題;
3.如果問題仍然存在,您可以嘗試以下解決方法:設定
<AndroidUseAssemblyStore>false</AndroidUseAssemblyStore>
在與 Xamarin.UITest 一起使用的配置中。
4.嘗試洗掉應用程式中的 obj 和 bin 檔案夾,然后重試。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/473727.html
標籤:xamarin xamarin.forms xamarin.android xamarin.ios 单体开发
上一篇:字體真棒代碼作為字串未按預期呈現
