在 Window 10 上构建 Android 项目时出错 [英] Error when building Android Project on Window 10

查看:41
本文介绍了在 Window 10 上构建 Android 项目时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为 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

Severity Code Description Project File Line Suppression State Error Failed to create JavaTypeInfo for class: Android.Support.V4.View.Accessibility.AccessibilityManagerCompat/IAccessibilityStateChangeListenerImplementor due to System.IO.DirectoryNotFoundException: Could not find a part of the path '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'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 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, Int32 bufferSize) at Xamarin.Android.Tools.Files.CopyIfStreamChanged(Stream stream, String destination) at 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 中:

  1. True - 强制构建过程使用较短的路径名.

  1. <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.

更改组策略:

  1. 启用 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 项目时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆