The "GenerateJavaStubs" task failed unexpectedly

user4689094 picture user4689094 · Dec 2, 2015 · Viewed 12.6k times · Source

I have created one new project in Visual studio and only che in .xml file (put two frame layouts) and when i debug the code i have one error, please told me the solution

Error   1   The "GenerateJavaStubs" task failed unexpectedly.
System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Max(IEnumerable`1 source)
at Xamarin.Android.Tools.TypeNameMapGenerator.WriteBinaryMapping(Stream o, Dictionary`2 mapping)
at Xamarin.Android.Tools.TypeNameMapGenerator.WriteJavaToManaged(Stream output)
at Xamarin.Android.Tasks.GenerateJavaStubs.UpdateWhenChanged(String path, Action`1 generator)
at Xamarin.Android.Tasks.GenerateJavaStubs.WriteTypeMappings(List`1 types)
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__20.MoveNext()    TMS_TabletView.Droid

Answer

Edgar.A picture Edgar.A · Jul 13, 2016

This still can happen if you use one of Xamarin Plugins that use CrossCurrentActivity, for example Plugins.Share and if you have Application class with [Application] tag. This is because on nuget installation it generates another Application class with same tag and that causes 'GenerateJavaStubs' failure.

Solution is simply delete one of Application classes / merge them into one.