" GenerateJavaStubs"任务失败

时间:2016-05-22 06:46:54

标签: c# android visual-studio xamarin

目前,我遇到这个问题时,我的头撞墙,这个错误阻止我构建和运行我的应用程序。这是一个PCL项目。

   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    

我在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程序集信息:

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)]

2 个答案:

答案 0 :(得分:25)

您尝试编译项目的路径是什么?

Windows对路径名称有限制,因此请尝试将项目移至较短的命名路径 例如,如果您使用C:\Users\YourUserName\Documents\VisualStudio2015\Projects\something的默认项目路径,则可以将其复制到C:\Dev

答案 1 :(得分:4)

只需复制here中的答案:

尝试在您的项目中添加此msbuild属性,这将缩短obj目录中的文件/文件夹名称

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

或者通过此操作将输出文件夹更改为更靠近C:\的一个文件夹

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

希望有帮助。