尝试使用Xamarin在VS2017中编译Android项目时,我遇到了错误。我得到一个字符串类型不允许错误,其中一个建议是更新我所有的Xamarin.Android引用。我发现了一个处理Xamarin.Core的observable的人,所以我安装了它。从那时起,我一直在解决分辨率错误。我已经尝试删除obj和bin目录并重新启动vs和我的笔记本电脑。
以下是错误的文字
Error The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.PathTooLongException: The specified path, file name, or both are too >long. The fully qualified file name must be less than 260 characters, and the >directory name must be less than 248 characters.
at System.IO.PathHelper.GetFullPathName()
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 > maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 >maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 >maxPathLength)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, >Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, >FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean >bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess >access, FileShare share)
at System.IO.File.Open(String path, FileMode mode)
at Xamarin.Tools.Zip.ZipEntry.DoExtract(IntPtr zipFile, String >destinationPath, FileMode outputFileMode, EntryExtractEventArgs args)
at Xamarin.Tools.Zip.ZipEntry.Extract(String destinationDir, String >destinationFileName, FileMode outputFileMode)
at Xamarin.Android.Tools.Files.ExtractAll(ZipArchive zip, String >destination, Action`2 progressCallback)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract (DirectoryAssemblyResolver res, 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.ITaskExecutio>nHost.Execute()
at >Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() LayoutExample.Android
答案 0 :(得分:4)
问题在于: System.IO.PathTooLongException:指定的路径,文件名或两者都太长。完全限定的文件名必须少于260个字符,目录名必须少于248个字符。
尝试将项目移动到另一个位置,例如&#34; C:/&#34; ,或更改项目的名称以获得更简短的内容
答案 1 :(得分:3)
答案 2 :(得分:0)
我刚刚回答了另一个问题(https://stackoverflow.com/a/44780549/31580)。
关键是,如果您的解决方案保存到路径较长的位置,那么这可能会导致某些文件的路径超过Windows的最大值(260个字符)
尝试将解决方案移动到C或D的根目录(如果有的话)。
答案 3 :(得分:0)
有同样的问题。这是我修复它的方式
答案 4 :(得分:0)
当我通过NuGet向我的项目添加对Xamarin.GooglePlayServices.Ads的引用时,我得到了这个。我一做到这一点就得到了和OP一样的问题。不幸的是,将我的代码移动到我的C驱动器的根目录也没有任何帮助;但是,根据Alper Ebicoglu的建议,我补充说......
<UseShortFileNames>True</UseShortFileNames>
...到我的构建配置的属性组中的项目文件。在Visual Studio中重新加载项目后,我能够构建我的项目。
希望这有帮助!