This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 36036 - error MSB4018: The "GenerateJavaStubs" task failed unexpectedly, error MSB4018: System.InvalidOperationException: Sequence contains no matching element
Summary: error MSB4018: The "GenerateJavaStubs" task failed unexpectedly, error MSB401...
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: 6.0.0
Hardware: PC Windows
: --- normal
Target Milestone: C6SR2
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2015-11-19 03:58 UTC by Niek Alink
Modified: 2016-03-03 05:15 UTC (History)
11 users (show)

See Also:
Tags: BZCU, BZRC6S1_C5SR5S1
Is this bug a regression?: ---
Last known good build:


Attachments

Description Niek Alink 2015-11-19 03:58:38 UTC
I updated xamarin yesterday to update 5.10 (build 871) and now i can't build my android project anymore!
its a pcl project and the shared project builds fine, no errors, but when i try to build the android project i see this error in the build output:


C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018: The "GenerateJavaStubs" task failed unexpectedly.
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018: System.InvalidOperationException: Sequence contains no matching element
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Xamarin.Android.Tasks.JavaTypeInfo.GetBaseConstructors(TypeDefinition type)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Xamarin.Android.Tasks.JavaTypeInfo.IsNonStaticInnerClass(TypeDefinition type)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at MonoDroid.Utils.JniType.ToJniName[T](T type, Func`2 decl, Func`2 name, Func`2 ns, Func`2 overrideName)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at MonoDroid.Utils.JniType.ToJniName(TypeDefinition type, ExportParameterKind exportKind)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at MonoDroid.Utils.JniType.ToJniName(TypeDefinition type)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Xamarin.Android.Tools.TypeNameMapGenerator.GetTypeMapping(Func`2 skipType, Func`2 key, Func`2 value)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Xamarin.Android.Tools.TypeNameMapGenerator.WriteJavaToManaged(Stream output)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Xamarin.Android.Tasks.GenerateJavaStubs.UpdateWhenChanged(String path, Action`1 generator)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Xamarin.Android.Tasks.GenerateJavaStubs.WriteTypeMappings(List`1 types)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Xamarin.Android.Tasks.GenerateJavaStubs.Run()
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()

And this is my version info on xamarin:

=== Xamarin Studio ===

Version 5.10 (build 871)
Installation UUID: 14e087ed-b880-414d-b848-f57901e37513
Runtime:
	Microsoft .NET 4.0.30319.34014
	GTK+ 2.24.23 (MS-Windows theme)
	GTK# 2.12.30

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 6.0.0 (Indie Edition)
Android SDK: C:\Users\niek.GDLMEDIA\AppData\Local\Android\android-sdk
	Supported Android versions:
		4.0.3 (API level 15)
		4.4   (API level 19)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1

SDK Build Tools Version: 23.0.1


Java SDK: C:\Program Files\Java\jdk1.8.0_66
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b18, mixed mode)

=== Xamarin Android Player ===

Not Installed

=== Build Information ===

Release ID: 510000871
Git revision: 4e9c5abb5ffdae12ba02ac49da83f8b2011dbb88
Build date: 2015-11-12 07:16:34-05
Xamarin addins: 55007ed0e56436f385d8e26394a45be563abc7e8
Build lane: monodevelop-windows-cycle6

=== Operating System ===

Windows 6.3.9600.0 (64-bit)

I tried everything i could think of:
Restore a backup from 4 days ago (the project was building just fine then, and the next day too)
reinstalled xamarin studio
reinstalled pcl tools
updated java runtime to the newest version
deleted JDK and installed the newest version
updated Android SDK items to the newest versions

i also searched for hours on the internet, but no solution worked.
Comment 1 Jonathan Pryor 2015-11-25 15:08:25 UTC
> System.InvalidOperationException: Sequence contains no matching element
>    at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
>    at Xamarin.Android.Tasks.JavaTypeInfo.GetBaseConstructors(TypeDefinition type)

This stack trace implies you've somehow come across a type which inherits from a type with no constructors, which offhand makes no sense at all. :-(

Could you please attach a repro?
Comment 2 Erlend Angelsen 2015-12-02 06:56:55 UTC
I get the same error when trying to build my Android project with Xamarin Studio 4 on mac.

This seems to be related as well. The proposed fix does not however work for me. I 
https://forums.xamarin.com/discussion/56081/build-error-after-update-to-the-latest-xamarin-packages
Comment 5 dean.ellis 2015-12-09 11:43:09 UTC
This problem only happens in the following scenario 


public class MainActivity : Activity {

  internal static class Foo {
  
      public class SomeClass : Java.Lang.Object {
      }
  
  }

}

The issue occurs when we try to pick out the constructors for the nested "SomeClass" class. It is tripping up the Java Stubs Generator. I am looking into why this happens and how to fix it.

WORKAROUND : Moving the "SomeClass" up a level fixes the issue. e.g 


public class MainActivity : Activity {

  internal static class Foo {
 
  } 
  
  public class SomeClass : Java.Lang.Object {
  
  }

}
Comment 6 dean.ellis 2016-01-25 16:41:04 UTC
Fixed in monodroid/master/5a042f5
Comment 7 Brendan Zagaeski 2016-01-25 22:49:20 UTC
I have now explicitly tested regression status to help decide when this fix should be merged.

Since this _is_ a regression, I will set initial target milestone to the next non-frozen target milestone.




## Regression status: regression in Xamarin.Android 6.0

BAD:  Xamarin.Android 6.0.0.34 (3efa14c)
GOOD: Xamarin.Android 5.1.9.0  (f7b9e87)


(I tested with both the full test case from non-public Comment 3 and the simplified test case from Comment 5.)
Comment 8 Erlend Angelsen 2016-02-14 19:37:05 UTC
I've been trying to work around the bug as stated in comment 5, but I can't find any nested classes in my code. Maybe some of my nugets have nested classes, but I can't seem to find a way to find them. I've also tried to downgrade my Xamarin Android version on both OSX and Windows without any luck. Has anyone got a pro-tip on how to get my Xamarin Android to build again?
Comment 9 Saurabh 2016-03-02 08:45:39 UTC
I am also able to reproduce this Issue with stable builds (XS 5.10.2.56 and XVS 4.0.1.96) using attached project in comment#3. This is the build output: https://gist.github.com/saurabh360/ef6e1b5d30280d8de434

I have also checked it on latest master builds (XS 6.1.0.129 and XVS 99.0.0.1658). This is working fine on these builds, No build error appears. This is the build output for the same: https://gist.github.com/saurabh360/ba70f32be41bb7ef44e8
Comment 10 Saurabh 2016-03-03 05:15:23 UTC
I have checked this Issue with latest C6SR2 builds and observed that attached project also build successfully. This is the screencast for the same: https://gist.github.com/saurabh360/afa7eed982c5e7f2c4d1

=== Xamarin Studio ===

Version 5.10.3 (build 26)
Installation UUID: 199d2043-a155-486c-868a-231f8258caba
Runtime:
	Microsoft .NET 4.0.30319.42000
	GTK+ 2.24.26 (MS-Windows theme)
	GTK# 2.12.30

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 6.0.2.1 (Enterprise Edition)
Android SDK: D:\android-sdk
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1.0

SDK Build Tools Version: 23.0.2


Java SDK: C:\Program Files\Java\jdk1.7.0_71
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Not Installed

=== Build Information ===

Release ID: 510030026
Git revision: ac9b7fcba9ee92ac30c8eb90f20c2228ce033efa
Build date: 2016-03-01 19:16:08-05
Xamarin addins: 633fde3bf405e3c402a51980976c431c204cf4f6
Build lane: monodevelop-windows-cycle6-c6sr2

=== Operating System ===

Windows 6.3.9600.0

Note You need to log in before you can comment on or make changes to this bug.