16

Currently banging my head against a wall with this issue, the error is preventing me from building and running my application. It is a PCL project.

   Error The "GenerateJavaStubs" task failed unexpectedly.
   System.IO.PathTooLongException: The specified path, file name, or both are  too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
   at System.IO.PathHelper.GetFullPathName()
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.GetFullPathInternal(String path)
   at System.IO.Path.GetFullPath(String path)
   at Xamarin.Android.Tasks.GenerateJavaStubs.Run()
   at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() ConstructionMobileApp.Droid C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets   1574    

My assembly info in the PCL:

using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("ConstructionMobileApp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConstructionMobileApp")]
[assembly: AssemblyCopyright("Copyright ©  2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Android Assembly Info:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;


[assembly: AssemblyTitle("ConstructionMobileApp.Droid")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConstructionMobileApp.Droid")]
[assembly: AssemblyCopyright("Copyright ©  2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
zen_1991
  • 599
  • 1
  • 10
  • 27
  • 3
    Whats the path to the project you are trying to compile? Windows has a limit on path names so try moving your project to a shorter named path. For example if you are using the default project path of C:\Users\YourUserName\Documents\VisualStudio2015\Projects\something then maybe copy it to c:\Dev – JimBobBennett May 22 '16 at 06:59
  • Thank you! I simply copied my project to a new location and opened it and the error is gone. Would have marked it as answer. – zen_1991 May 22 '16 at 08:37

2 Answers2

28

Whats the path to the project you are trying to compile?

Windows has a limit on path names so try moving your project to a shorter named path.
For example if you are using the default project path of C:\Users\YourUserName\Documents\VisualStudio2015\Projects\something then maybe copy it to C:\Dev.

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
JimBobBennett
  • 2,149
  • 14
  • 11
9

Just copying the answer from here:

Try adding this msbuild property in your project that will shorten the file/folder names on the obj directory

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

Or this to change the output folder to a one closer to the C:\

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <IntermediateOutputPath>C:\MyFolder\MyProj</IntermediateOutputPath>
</PropertyGroup>

Hope it helps.

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632