问题描述
在为 Android 构建时,我一直遇到此错误:
When building for Android I keep having this error:
严重性代码描述项目文件行抑制状态错误未能为类创建 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\accessibility\AccessibilityManagerCompat_AccessibilityStateChangeListenerImplementor.java'.在 System.IO.__Error.WinIOError(Int32 errorCode, String mightFullPath)在 System.IO.FileStream.Init(字符串路径,FileMode 模式,FileAccess 访问,Int32 权限,Boolean useRights,FileShare 共享,Int32 bufferSize,FileOptions 选项,SECURITY_ATTRIBUTES secAttrs,String msgPath,Boolean bFromProxy,Boolean useLongPath,Boolean checkHost)在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)在 Xamarin.Android.Tools.Files.CopyIfStreamChanged(流流,字符串目标)在 Xamarin.Android.Tasks.Generator.CreateJavaSources(TaskLoggingHelper log, IEnumerable`1 javaTypes, String outputPath, String applicationJavaClass, Boolean useSharedRuntime, Boolean generateOnCreateOverrides, Boolean hasExportReference) Client1.Playground.Android
是什么原因造成的?我如何解决它?似乎不会发生在 CI 构建中.
What is causing it? How do I fix it? Doesn't seem to happen on the CI builds.
推荐答案
这里有一些方法可以用来解决 MAX_PATH
长度问题:
Here's a few methods you can use to fix MAX_PATH
length issues:
在 Xamarin.Android .csproj 中:
- 强制构建过程使用较短的路径名.
<UseShortFileNames>True</UseShortFileNames>
- Forces the build process to use shorter path names.
<IntermediateOutputPath>C:\Projects\MyApp</IntermediateOutputPath>
- 指定一个公共的中间输出根以制作更短的路径.
<IntermediateOutputPath>C:\Projects\MyApp</IntermediateOutputPath>
- Specifies a common intermediate output root to make a shorter path.
更改组策略:
- 启用 Win32 长路径支持(在 Visual Studio 2019+ 中受支持):https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/
这篇关于在 Window 10 上构建 Android 项目时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!