7
votes

Following this tutorial https://github.com/Vidyo/vidyo.io-connector-xamarin I downloaded the app without making any changes.

When I build the app, I get the following error:

Severity Code Description Project File Line Suppression State Error Failed to create JavaTypeInfo for class: Android.Support.V4.View.Accessibility.AccessibilityManagerCompat/ITouchExplorationStateChangeListenerImplementor due to MAX_PATH: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\User\Desktop\vidyo.io-connector-xamarin-master\vidyo.io-connector-xamarin-master\VidyoConnector.Android\obj\Debug\90\android\src\mono\android\support\v4\view\accessibility\AccessibilityManagerCompat_TouchExplorationStateChangeListenerImplementor.java'.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.InternalDelete(String path, Boolean checkHost) at System.IO.File.Delete(String path) 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, String androidSdkPlatform, Boolean useSharedRuntime, Boolean generateOnCreateOverrides, Boolean hasExportReference) VidyoConnector.Android

What is the possible fix for this?

4
I download this sample , and also have issue when running project in android, so I suggest you can feecback this issue on this issue link:github.com/Vidyo/vidyo.io-connector-xamarin/issues - Cherry Bu - MSFT

4 Answers

9
votes

That seems a problem with long path in windows. Put the project folder on the root, say C://yourproject. Then, clean your solution and build.

3
votes

@LawrenceWlt is correct but I would like to add some more information.

Is is due to Maximum Path Length Limitation

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters.

https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation

If you are on Windows 10, Version 1607 or later you can Enable Long Paths:

The registry key Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled (Type: REG_DWORD) must exist and be set to 1.

The application manifest must also include the longPathAware element.

<application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
        <ws2:longPathAware>true</ws2:longPathAware>
    </windowsSettings>
</application>

https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation#enable-long-paths-in-windows-10-version-1607-and-later

I got a similar error from Experimental Mobile Blazor Bindings:

https://github.com/xamarin/MobileBlazorBindings

Failed to generate Java type for class: Android.Support.V4.View.Accessibility.AccessibilityManagerCompat/IAccessibilityStateChangeListenerImplementor due to MAX_PATH: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\User\Desktop\MobileBlazorBindings-master\samples\MobileBlazorBindingsXaminals\MobileBlazorBindingsXaminals.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.File.InternalDelete(String path, Boolean checkHost) at System.IO.File.Delete(String path) at Xamarin.Android.Tools.Files.CopyIfStreamChanged(Stream stream, String destination) at Xamarin.Android.Tasks.GenerateJavaStubs.CreateJavaSources(IEnumerable`1 javaTypes, TypeDefinitionCache cache) MobileBlazorBindingsXaminals.Android

2
votes

There is another solution that hasn't been mentioned yet: Create a Directory Junction and point it to your solution directory. Place the junction at the root-level, then run the solution from there.

This approach will enable you to workaround the MAX_PATH issue without having to move your project or upgrade to Windows 10.

For example, let's say you store all your code in C:\dev, all your repos in C:\dev\repos, all your Git repos in C:\dev\repos\git, all your Xamarin Git repos in C:\dev\repos\git\xamarin, and all the mobile apps you've built for your largest client in C:\dev\repos\git\xamarin\isis (hey it's not my place to judge). Your latest project can be found in C:\dev\repos\git\xamarin\isis\satellite-tracker\src, but you can't get it to build because the path is too long.

So we create a new directory, C:\J, which will hold this and any other junctions we create for this workaround on other projects. Then open a command prompt as Administrator and navigate to C:\J. Then enter the following command:

mklink /J SatTrack C:\dev\repos\git\xamarin\isis\satellite-tracker\src

Now you can access your solution file from C:\J\SatTrack. If you open it from there, Visual Studio will use that path instead of the longer one and you should be fine after a clean/rebuild.

0
votes

A simple solution that works great is changing the build output folder in Android Project -> Properties -> Build -> Output path