【问题标题】:Can't build "hello world" Xamarin app for Android无法为 Android 构建“hello world”Xamarin 应用程序
【发布时间】:2018-08-16 20:55:47
【问题描述】:

我收到此错误:

Severity    Code    Description Project File    Line    Suppression State
Error       The "Javac" 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.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths)
   at System.IO.Path.NewNormalizePath(String path, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.GetFullPathInternal(String path)
   at System.IO.FileInfo.Init(String fileName, Boolean checkHost)
   at System.IO.FileInfo..ctor(String fileName)
   at Xamarin.Android.Tasks.ZipArchiveEx.AddFiles(String folder, String folderInArchive)
   at Xamarin.Android.Tasks.ZipArchiveEx.AddDirectory(String folder, String folderInArchive)
   at Xamarin.Android.Tasks.Javac.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() XamarinApp1.Android     

我的应用程序的名称是 XamarinApp1;肯定不会太长吧?

这是一个开箱即用的默认 Xamarin Android XAML 项目...模板没有更改;我只是尝试构建它...

【问题讨论】:

  • Error is pretty explanatory: "System.IO.PathTooLongException: The specified path, file name, or both are too long. 完全限定的文件名必须少于 260 个字符,并且目录名必须少于 248 个字符。”检查目录路径加项目名称,即全限定文件名。
  • 向 Windows 奇怪的目录长度限制问好。考虑将解决方案移至更高的目录,例如 `c:\Develop\XamarinApp1`。
  • 嗯,解决方案在C:\Users\edkol\Documents\Visual Studio 2017\Projects\XamarinApp1,下面有2个项目;不应该接近 260 个字符......不过,将 XamarinApp1 移动到 C:\VSProjects 似乎已经修复了它......有点?现在我在 styles.xml 中收到所有这些错误,比如“找不到与给定名称匹配的资源:attr 'windowActionBar'。”

标签: c# android visual-studio xamarin


【解决方案1】:

打开 Android .csproj 并插入此 PropertyGroup,将 IntermediateOutputPath 替换为您机器中的短路径。 MSBuild 将在 "E:\temp\MyApp" 此处创建输出文件。

<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <UseShortFileNames>True</UseShortFileNames>
    <IntermediateOutputPath>E:\temp\MyApp</IntermediateOutputPath>
  </PropertyGroup>
...

如果您想了解有关此错误的更多信息,请查看:

How do I resolve a PathTooLongException error?

Shorter Internal Path Names (Experimental)

【讨论】:

    猜你喜欢
    • 2016-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-14
    • 2014-01-11
    相关资源
    最近更新 更多