gpt4 book ai didi

c# - Visual Studio 2017 更新到 15.8.1/15.8.2 后的 Xamarin Android 应用项目构建问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:01:21 24 4
gpt4 key购买 nike

将 Visual Studio 2017 升级到 15.8.1 并使用 Android SDK 版本 28(支持 Android 9.0 P)后,我们在构建基于 Xamarin 的 Android App C# 项目时遇到问题并出现以下错误:

_LinkAssembliesNoShrink:
Creating "obj\\ObRelease\MonoAndroid90\link.flag" because "AlwaysCreate" was specified.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : Failed to read 'D:\MyAndroidApp\obj\ObRelease\MonoAndroid90\android\assets\Mono.Android.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : Mono.Cecil.Cil.SymbolsNotMatchingException: Symbols were found but are not matching the assembly [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader, Boolean throwIfSymbolsAreNotMaching) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleDefinition.ReadModule(Disposable`1 stream, String fileName, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : Failed to read 'D:\MyAndroidApp\obj\ObRelease\MonoAndroid90\android\assets\System.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : Mono.Cecil.Cil.SymbolsNotMatchingException: Symbols were found but are not matching the assembly [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader, Boolean throwIfSymbolsAreNotMaching) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleDefinition.ReadModule(Disposable`1 stream, String fileName, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : Failed to read 'D:\MyAndroidApp\obj\ObRelease\MonoAndroid90\android\assets\System.Xml.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : Mono.Cecil.Cil.SymbolsNotMatchingException: Symbols were found but are not matching the assembly [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader, Boolean throwIfSymbolsAreNotMaching) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleDefinition.ReadModule(Disposable`1 stream, String fileName, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning : at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: The "GenerateJavaStubs" task failed unexpectedly. [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object. [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager.<>c.<ToJniNameFromAttributes>b__42_0(CustomAttribute a) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager.ToJniNameFromAttributes(TypeDefinition type) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager.ToJniName[T](T type, Func`2 decl, Func`2 name, Func`2 ns, Func`2 overrideName, Func`2 shouldUpdateName) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager.ToJniName(TypeDefinition type, ExportParameterKind exportKind) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager.ToJniName(TypeDefinition type) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Java.Interop.Tools.JavaCallableWrappers.TypeNameMapGenerator.GetTypeMapping(Func`2 skipType, Func`2 key, Func`2 value) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Java.Interop.Tools.JavaCallableWrappers.TypeNameMapGenerator.WriteJavaToManaged(Stream output) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Xamarin.Android.Tasks.GenerateJavaStubs.UpdateWhenChanged(String path, Action`1 generator) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Xamarin.Android.Tasks.GenerateJavaStubs.WriteTypeMappings(List`1 types) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Xamarin.Android.Tasks.GenerateJavaStubs.Run(DirectoryAssemblyResolver res) [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Xamarin.Android.Tasks.GenerateJavaStubs.Execute() [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\MyAndroidApp.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [D:\MyAndroidApp.csproj]
Done Building Project "D:\MyAndroidApp.csproj" (default targets) -- FAILED.

任何线索或任何解决方案或任何解决方法?

更新:即使在将 Visual Studio 2017 更新到 15.8.2 后,问题仍然存在。

最佳答案

不是 Xamarin Android 项目的专家,但只想提供一些建议:

  1. 根据 this老错误,这可能是由于悬挂引用而发生的。因此,请检查您的引用资料、清理您的项目、手动清理输出(发布/调试)文件夹并再次尝试构建项目。
  2. 根据错误消息,错误来自 this 中的 ToJniNameFromAttributes 方法文件。所以最好检查对 Java.interop 包的引用。
  3. 最后,您可以创建一个新的 Xamarin Android 应用程序,然后并排比较工作项目和非工作项目的项目配置文件(csproj 文件、卸载项目并在解决方案资源管理器中右键单击以编辑 csproj 文件)以寻找有问题的项目配置下降。

希望对您有所帮助!

问题具体答案:

以下是我为具体解决问题所做的项目引用更改。只需将其添加到此处,因为它对阅读答案的人理解问题\解决方案更有帮助。

原文引用如下:

<Reference Include="Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Mono.Android.Export, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="mscorlib">
<Private>False</Private>
</Reference>
<Reference Include="System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>

更改后的引用(构建通过):

<Reference Include="Mono.Android" />
<Reference Include="Mono.Android.Export" />
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />

关于c# - Visual Studio 2017 更新到 15.8.1/15.8.2 后的 Xamarin Android 应用项目构建问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52078278/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com