在 Window 10 上构建 Android 项目时出错

Iai*_*ith 1 windows visual-studio xamarin.android xamarin

在为 Android 构建时,我不断遇到此错误:

严重性代码描述项目文件行抑制状态错误无法为类创建 JavaTypeInfo:Android.Support.V4.View.Accessibility.AccessibilityManagerCompat/IAccessibilityStateChangeListenerImplementor 由于 System.IO.DirectoryNotFoundException:找不到路径的一部分“C:\Users” \Iain Smith\Documents\Developer\Work\Clients\Client1\Project1\Xamarin.Dev.Playground\Source\Client1.Playground.Android\obj\Debug\90\android\src\mono\android\support\v4\view\可访问性\AccessibilityManagerCompat_AccessibilityStateChangeListenerImplementor.java'。在 System.IO.__Error.WinIOError(Int32 errorCode, String MaybeFullPath) 在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options,

是什么原因造成的?我如何解决它?在 CI 构建中似乎没有发生。

Jon*_*las 6

您可以使用以下几种方法来解决MAX_PATH长度问题:

在 Xamarin.Android .csproj 中:

  1. <UseShortFileNames>True</UseShortFileNames> - 强制构建过程使用较短的路径名。

  2. <IntermediateOutputPath>C:\Projects\MyApp</IntermediateOutputPath> - 指定一个公共的中间输出根来制作更短的路径。

更改组策略:

  1. 启用 Win32 长路径支持(Visual Studio 2019+ 支持):https ://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-视窗-10/

  • 我可能应该写一篇关于它的博客文章!:P (2认同)