3

When building for Android I keep having this error:

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

What is causing it? How do I fix it? Doesn't seem to happen on the CI builds.

2 Answers 2

11

Here's a few methods you can use to fix MAX_PATH length issues:

Within a Xamarin.Android .csproj:

  1. <UseShortFileNames>True</UseShortFileNames> - Forces the build process to use shorter path names.

  2. <IntermediateOutputPath>C:\Projects\MyApp</IntermediateOutputPath> - Specifies a common intermediate output root to make a shorter path.

Changing the group policy:

  1. Enable Win32 Long Path Support (Supported in Visual Studio 2019+): https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/
Sign up to request clarification or add additional context in comments.

3 Comments

Oooh I did not know this, some useful bits here!
I should probably write a blog post on it! :P
You should @JonDouglas
1

This is due to the Max Path length on Windows, Changed my directory from:

C:\Users\Iain Smith\Documents\Developer\Work\Clients\Client1\Project1\Xamarin.Dev.Playground\Source\Client1.Playground.Android\

to:

C:\Developer\Work\Clients\Client1\Project1\Xamarin.Dev.Playground\Source\Client1.Playground.Android\

1 Comment

moving the project/sln directory to a shorter path fixed this for me as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.