Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何修复Xamarin表单Android构建中的“ConvertResourcesCase”?_Android_Visual Studio_Xamarin.forms_Xamarin.android - Fatal编程技术网

如何修复Xamarin表单Android构建中的“ConvertResourcesCase”?

如何修复Xamarin表单Android构建中的“ConvertResourcesCase”?,android,visual-studio,xamarin.forms,xamarin.android,Android,Visual Studio,Xamarin.forms,Xamarin.android,我在构建Xamarin Forms Android模块应用程序时遇到了一个问题。 下面是我经常遇到的错误 Severity Code Description Project File Line Suppression State Error The "ConvertResourcesCases" task failed unexpectedly. System.IO.PathTooLongException: The specified path, file name, or both are

我在构建Xamarin Forms Android模块应用程序时遇到了一个问题。 下面是我经常遇到的错误

Severity Code Description Project File Line Suppression State
Error The "ConvertResourcesCases" 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.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.InternalGetDirectoryName(String path)
  at System.IO.Path.GetDirectoryName(String path)
  at Xamarin.Android.Tools.Files.CopyIfChanged(String source, String destination)
  at Xamarin.Android.Tasks.MonoAndroidHelper.CopyIfChanged(String source, String destination)
  at Xamarin.Android.Tasks.ConvertResourcesCases.FixupResources(ITaskItem item, Dictionary 2 acwMap)
  at Xamarin.Android.Tasks.ConvertResourcesCases.FixupResources(Dictionary 2 acwMap)
  at Xamarin.Android.Tasks.ConvertResourcesCases.Execute()
  at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
  at Microsoft.Build.BackEnd.TaskBuilder<ExecuteInstantiatedTask>d__26.MoveNext() EHG.EmployeeApp.Mobile.Android
请建议并帮助我,提前谢谢

ConvertResourcesCases任务意外失败。 System.IO.PathTooLongException:指定的路径、文件名或两者都是。\n 太长了。完全限定文件名必须小于260 字符,并且目录名称必须少于248个字符

这意味着路径超出了Windows允许的最大值。尝试将解决方案移动到磁盘的根目录,以便路径更小。例如,将其移动到:

D:\YourProject
编辑:

如果我切换到调试模式工作正常,我只在发布模式下面临这个问题

我认为在发布模式下,Windows有更严格的检查机制。为了验证这一点,我创建了一个演示,以下是项目路径:

C:\Users\username\Downloads\CollapsingToolbarLayout\CollapsingToolbarLayout123\CollapsingToolbarLayout1234\CollapsingToolbarLayoutasd\CollapsingToolbarLayoutaasda\App1
它在调试模型中运行良好,但在发布模式中面临完全相同的问题

但当我将此项目移至:

C:\Users\username\Downloads\CollapsingToolbarLayout\CollapsingToolbarLayout123\App1
它可以在调试模式和发布模式下正常工作。所以你可以将你的项目转移到一个更短的路径,我认为这是一个永久的解决方案

Windows具有最大路径长度限制。你可以从以下几个方面看到:

最大路径长度限制在Windows API中,除了以下段落中讨论的一些例外,路径的最大长度是MAX_Path,定义为260个字符。本地路径按以下顺序构造:驱动器号、冒号、反斜杠、由反斜杠分隔的名称组件和终止的空字符。例如,驱动器D上的最大路径是D:\256个字符的路径字符串,其中表示当前系统代码页的不可见终止空字符。此处使用的字符<>是为了清晰可见,不能作为有效路径字符串的一部分。这就是你有这个问题的原因

另一个解决方案是使用长路径工具。作为博根:

避免此问题的最简单方法是将源代码移动到C:/drive或路径中字符较少的其他位置,或安装长路径工具


尝试删除bin和obj文件夹。这有效吗?我尝试过这个,我只在发布模式下面对这个问题,如果我切换到调试模式工作正常,是否有其他解决方案,因为我以前遇到过这个问题,并且通过减小路径大小来修复。现在同样的问题,我正在寻找其他解决方案来永久解决它。谢谢即使您缩短了项目路径,它仍然只在调试模型中工作?抱歉,我还无法解决此问题,但在对visual studio进行一些更改后,我面临Java代码exit2问题,然后启用了Multidex,我将获得代码空间;Android sdktools路径中的问题。@Ganesh,你是什么意思;问题