警告:在Visual Studio 2015中创建跨平台Xamarin空白应用程序(Xamarin.Form可移植)

时间:2016-10-22 21:43:36

标签: visual-studio xamarin xamarin.forms

每当我尝试创建上述类型的新项目时,我都会收到以下4个警告:

预更新Nuget

1

Warning IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.   xamarinProj1.Droid

2

The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'xamarinProj1, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'xamarinProj1.dll'
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() xamarinProj1.Droid          Build

3

Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.   xamarinProj1.UWP            Build   

4

Cannot resolve Assembly or Windows Metadata file 'System.Runtime.dll'   xamarinProj1.UWP    c:\users\user\documents\visual studio 2015\Projects\xamarinProj1\xamarinProj1\xamarinProj1.UWP\xamarinProj1.UWP.csproj      Build   

后的NuGet:

2

The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'xamarinProj1, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'xamarinProj1.dll'
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() xamarinProj1.Droid          Build

3

IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.   xamarinProj1.Droid      1   IntelliSense    Active

5

Severity    Code    Description Project File    Line    Source  Suppression State
Warning     Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Runtime" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Text.RegularExpressions" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.IO" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Globalization" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Xml.ReaderWriter" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.ObjectModel" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Linq" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Runtime.Extensions" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Collections" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Threading" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Diagnostics.Debug" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Reflection" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Linq.Expressions" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Threading.Tasks" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Dynamic.Runtime" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /></dependentAssembly></assemblyBinding>    xamarinProj1.Droid          Build

请注意,即使它在模拟器中发出警告,我也看不到该应用程序正在运行(默认情况下为#34;欢迎使用Xamarin&#34;标签)。此外,当我点击错误#5时,它将重新出现在下一个版本中。

我试图解决的问题:

  1. 我已经更新了项目Nuget包并安装了最新的表单,我也尝试在Nuget管理器中为该项目安装所有更新,但仍然存在问题
  2. 我重新安装了Visual Studio和Xamarin
  3. 我安装了各种版本的JDK并尝试更改工具 - &gt;选项 - &GT; Xamarin-&GT; Android各种JDK文件夹:x64:jdk1.8.0_102,x86:jdk1.7.0_55,jdk1.7.0_79,jdk1.7.0_80,jdk1.8.0_101 (请注意,在您的手动安装中,您建议安装x86,因此我也尝试过这样做)
  4. 从英特尔网站安装了最新的XHAM。
  5. 更新了Android SDK并基本上安装了所有工具(包括平台等)和所有API 23和API 24内容,以及听起来不错的各种附加内容也安装了最新的NDK
  6. 将项目最低目标更改为更低的Android固件版本(14)
  7. 我已通过Visual Studio更新了Xamarin
  8. 搜索网络,甚至尝试重新安装Nuget包管理器作为建议
  9. 我必须提到原来的安装程序在我重新安装Xamarin时已经冻结了(在我之前提到的卸载之后),并且安装程序仍然失败,所以我根据{已安装它{3}}

4 个答案:

答案 0 :(得分:2)

如果您正在开发Visual Studio中的跨平台应用程序,那么请检查您的公共项目是否是为所有其他操作系统共享代码的项目,以及特定项目的引用是否为nuget包没有重叠,以至于存在歧义。 我遇到了同样的问题,删除公共引用很快就解决了我的问题。 在我的案例中常见的包被命名为&#39; Windows&#39;。

您可以像这样查看解决方案资源管理器。 enter image description here

答案 1 :(得分:2)

您可能想尝试:

  1. 清除解决方案中的所有项目
  2. 手动删除所有 bin &amp;解决方案中的 obj 目录
  3. 将所有NuGet软件包(解决方案范围内)更新为“最新稳定版”
  4. 程序包管理器控制台中运行Update-Package –reinstall(并验证任何引用上没有警告)
  5. 此外,我遇到了 Xamarin.Forms 的错误,要求我从Android项目中卸载 Xamarin.Forms NuGet包,然后重新安装“最新稳定版”版本的Xamarin.Forms(不是 Xamarin.Android.Support。* 包 - 这些将在重新安装 Xamarin.Forms 期间自动安装。)

    执行上述操作通常可以解决这些奇怪的错误。我希望这有帮助-  祝你好运!

答案 2 :(得分:0)

您可以检查/确认是否已在Visual Studio中启用恢复/检查缺少Nuget包的功能?

打开Visual Studio - &gt;工具 - &gt;选项 - &gt; NuGet包管理器 - &gt;一般。确保&#34;允许Nuget下载丢失的包&#34;的复选框。和#34;在Visual Studio中构建期间自动检查缺少的包&#34;检查。完成后,尝试Clean然后Build解决方案。

Or

您可以通过Package Manager控制台安装Mirosoft.NETCore.UniversalWindowsPlatform包: PM&GT;安装包Microsoft.NETCore.UniversalWindowsPlatform

之后一切都会正常工作。 参考文献  reference1 reference2

答案 3 :(得分:0)

我遇到了同样的问题,发现我的VS Solution目录的路径太长了。我将我的解决方案移到D盘的根部,一切都很顺利。