Iain Smith
Iain Smith

Reputation: 9703

Error when building Android Project on Window 10

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.

Upvotes: 3

Views: 5291

Answers (2)

Jon Douglas
Jon Douglas

Reputation: 13176

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/

Upvotes: 11

Iain Smith
Iain Smith

Reputation: 9703

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\

Upvotes: 1

Related Questions