Path too Long during Build: How to change Directory for Xamarin Android

marxxliveatmarxxliveat USMember
edited November 2016 in Xamarin.Android

Hi,

i can't build my Xamarin Forms based Application for Android with my company user because Xamarin Android apparently installs all of it's Librarys like

Xamarin.Android.Support.Animated.Vector.Drawable
Xamarin.Android.Support.Design
Xamarin.Android.Support.v4
...

in the User Profile! As the user i log into my machine including domain consists of 26 characters, this results in Path too long exceptions when i try to build the solution with this users. I get errors like this:

Severity Code Description Project File Line Suppression State
Error Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r29.zip and extract it to the C:\Users\xxxxxxxxxxxxxxxxxxxxxxxxxxxx\AppData\Local\Xamarin\Xamarin.Android.Support.Animated.Vector.Drawable\23.3.0.0\content directory. MyMobileApplicationName.Droid
Error Reason: Der angegebene Pfad und/oder Dateiname ist zu lang. Der vollständig qualifizierte Dateiname muss kürzer als 260 Zeichen und der Pfadname kürzer als 248 Zeichen sein. MyMobileApplicationName.Droid
Error Please install package: 'Xamarin.Android.Support.Vector.Drawable' available in SDK installer. Java library file C:\Users\xxxxxxxxxxxxxxxxxxxxxxxxxxxx\AppData\Local\Xamarin\Xamarin.Android.Support.Vector.Drawable\23.3.0.0\content\classes.jar doesn't exist. MyMobileApplicationName.Mobile.Droid
...

My "workaround" to this problem is to create a local user with only 3 characters in the user name and run Visual Studio under this account.
Then the solution builds fine without problems.

However, as you can imagine, this is not a permanent solution.

So my question is:

How can i change the folder from where Xamarin Android gets it's Librarys to something shorter (maybe even something, every user can use on the machine, which IMHO make total sense).

I'm using Visual Studio 2015 Enterprise and Windows 10.

Thank you very much for any help!

Kind regards
Markus

Posts

  • marxxliveatmarxxliveat USMember

    Solved with activating Long paths in Windows 10 Anniversary Update:

    Thanks to @kentucker:

    @kentucker said:
    You need to move the root of the project to a shorter path. For example by default the projects are created in c:\users[user name\documents\visual studio 2015\projects. If you create the project in c:\MyProjects you wont get that error.

    If you have the win 10 Anniversary edition you can try enabling long file names.

    https://csharp2ae.blogspot.com/2016/08/how-to-enable-long-file-names-in.html

    Also found this guide here to activate long paths in Win10 Anniversary:
    http://winaero.com/blog/how-to-enable-ntfs-long-paths-in-windows-10/

    After restarting the machine i had to manually download the package stated in the error message and expand it to the right location in the user profile (also stated in the error message).
    From then on it was working again.

  • marxxliveatmarxxliveat USMember

    Solved in Windows 10 Anniversary Update by activating long paths according to those instructions:
    https://csharp2ae.blogspot.com/2016/08/how-to-enable-long-file-names-in.html
    http://winaero.com/blog/how-to-enable-ntfs-long-paths-in-windows-10/

    After restarting my machine, manually downloading and expanding the package (as stated in the error message) it worked for me!

    Thanks to @kentucker for pointing me into the right direction.

  • marxxliveatmarxxliveat USMember

    Solved with activating Long paths in Windows 10 Anniversary Update:

    Thanks to @kentucker:

    @kentucker said:
    You need to move the root of the project to a shorter path. For example by default the projects are created in c:\users[user name\documents\visual studio 2015\projects. If you create the project in c:\MyProjects you wont get that error.

    If you have the win 10 Anniversary edition you can try enabling long file names.

    https://csharp2ae.blogspot.com/2016/08/how-to-enable-long-file-names-in.html

    Also found this guide here to activate long paths in Win10 Anniversary:
    http://winaero.com/blog/how-to-enable-ntfs-long-paths-in-windows-10/

    After restarting the machine i had to manually download the package stated in the error message and expand it to the right location in the user profile (also stated in the error message).
    From then on it was working again.

  • marxxliveatmarxxliveat USMember

    Solved in Windows 10 Anniversary Update by activating long paths according to those instructions:
    https://csharp2ae.blogspot.com/2016/08/how-to-enable-long-file-names-in.html
    http://winaero.com/blog/how-to-enable-ntfs-long-paths-in-windows-10/

    After restarting my machine, manually downloading and expanding the package (as stated in the error message) it worked for me!

    Thanks to @kentucker for pointing me into the right direction.

  • russellblogrussellblog AEMember

    I would recommend in this case to try "Long Path Tool" program.

  • @marxxliveat said:
    After restarting the machine i had to manually download the package stated in the error message and expand it to the right location in the user profile (also stated in the error message).
    From then on it was working again.

    Can you explain this a bit more? I enabled the long paths in my registry but I'm still getting this error. It's driving me mad :(

  • DumpsterNinjaDumpsterNinja USMember ✭✭

    @marxxliveat it's over a year later, so i'm sure you already solved it, but for me i followed the insturctions here:

    docs.microsoft.com/en-us/xamarin/android/troubleshooting/questions/path-too-long-exception (sorry i can't post link because it says i haven't been around long enough)

    the link states that you can add a couple settings to your android csproj file:

    <PropertyGroup>
        <UseShortFileNames>True</UseShortFileNames>
    </PropertyGroup>
    

    and if it still doesn't work, you can tell msbuild to use a shorter, itermediate location (which is what i had to do):

    <PropertyGroup>
        <IntermediateOutputPath>C:\temp</IntermediateOutputPath>
    </PropertyGroup>
  • EvgeniyZverevEvgeniyZverev USMember ✭✭
    edited September 20

    @DumpsterNinja said:
    @marxxliveat it's over a year later, so i'm sure you already solved it, but for me i followed the insturctions here:

    docs.microsoft.com/en-us/xamarin/android/troubleshooting/questions/path-too-long-exception (sorry i can't post link because it says i haven't been around long enough)

    the link states that you can add a couple settings to your android csproj file:

    <PropertyGroup>
    >     <UseShortFileNames>True</UseShortFileNames>
    > </PropertyGroup>
    > 

    and if it still doesn't work, you can tell msbuild to use a shorter, itermediate location (which is what i had to do):

    <PropertyGroup>
    >     <IntermediateOutputPath>C:\temp</IntermediateOutputPath>
    > </PropertyGroup>

    Worked for me. I used to patch the registry + manifests for MSBuild.exe, aapt.exe and devenv.exe for quite some time. Now its less pain. And I totally missed the update from MS. Thanks!

    I would add the link to the source though: How do I resolve a PathTooLongException error?

Sign In or Register to comment.