Bug 5152 - The "GenerateJavaStubs" task failed unexpectedly - 4.2
Summary: The "GenerateJavaStubs" task failed unexpectedly - 4.2
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.2.x
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-05-17 17:07 UTC by Stuart Lodge
Modified: 2014-11-13 11:26 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Full build output (5.33 MB, application/x-zip-compressed)
2012-05-17 17:07 UTC, Stuart Lodge
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Stuart Lodge 2012-05-17 17:07:16 UTC
Created attachment 1911 [details]
Full build output

This is following up from a discussion on the Android mailing list.

I've been working with a lot of PCL/PLP-based projects in WP7, MonoDroid and MonoTouch

To get these building requires some customisation of a VS2010/VS11/MonoDroid environment - instructions on:
- http://slodge.blogspot.co.uk/2012/05/portable-class-libraries-in-mvvmcross.html
- http://slodge.blogspot.co.uk/2012/04/using-portable-library-tools-for.html

These projects were previously all building under the alpha release of 4.2

However, since upgrading to the full release of 4.2:
- I've had to change a lot of projects because of implicit/explicit reference problems - please go back to supporting implicit :)
- I've not been able to build one particular project - the conference sample.

The build window really isn't telling me much. Is there any way I can get more debug info?

The code in question is the vNext branch of https://github.com/slodge/MvvmCross as checked in right now.

I'm happy to work with you to try to diagnose this... I realise that some of the things I'm doing with PLPs are "bleeding edge" - but I have had lots of nice input from MS BCL team in Redmond, and I did have all of this working in the alpha release.

Stuart (me@slodge.com)
Comment 1 Jonathan Pobst 2012-05-17 17:42:58 UTC
Error from the log:

The "GenerateJavaStubs" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
   at CustomAttributeProviderRocks.<GetCustomAttributes>c__Iterator2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
   at Xamarin.Android.Tasks.JavaTypeInfo.<JavaTypeInfo>m__3(TypeDefinition d)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
   at Xamarin.Android.Tasks.JavaTypeInfo..ctor(TypeDefinition type, String outerType)
   at Xamarin.Android.Tasks.Generator.CreateJavaSources(List`1 javaTypes, String outputPath, Boolean useSharedRuntime, Boolean hasExportReference)
   at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__1c.MoveNext()
Comment 2 Stuart Lodge 2012-05-17 18:16:09 UTC
A smaller solution to reproduce this - which only requires the VS11 and MonoDroid conversions for PCL/PLP is available as MvvmCross_For_Xam.sln in https://github.com/slodge/MvvmCross/tree/vnext

It shows the same problem

The same basic code, but without the huge refactoring is building fine - e.g. see https://github.com/slodge/MvvmCrossConference from which I just released to Droid fine

I don't know if the problem is in PCL or in some rogue non-updated file reference - is there any way I could add anything to the error trace by editing the msbuild file?

Stuart
Comment 4 Stuart Lodge 2012-05-25 11:41:55 UTC
Jonathan
I'm so sorry - I never got a notification of this post.
I did get a notifcation when the priority changed - but not of this "you can try" post.
Am on it now.
Stuart
Comment 5 Stuart Lodge 2012-05-25 11:53:09 UTC
In latest release (4.2.2) the error is much more clearly identified:

I'm digging further into this now.

Stuart


Error	10	The "GenerateJavaStubs" task failed unexpectedly.
System.ApplicationException: Failed to create JavaTypeInfo for class: Cirrious.MvvmCross.Binding.Android.Views.MvxBindingMapActivityView`1 ---> System.InvalidOperationException: Unable to resolve interface type 'Cirrious.MvvmCross.Binding.Android.Interfaces.Views.IMvxBindingActivity'. Are you missing an assembly reference?
   at Xamarin.Android.Tasks.JavaTypeInfo.<JavaTypeInfo>m__2(TypeReference r)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
   at Xamarin.Android.Tasks.JavaTypeInfo..ctor(TypeDefinition type, String outerType)
   at Xamarin.Android.Tasks.Generator.CreateJavaSources(List`1 javaTypes, String outputPath, Boolean useSharedRuntime, Boolean hasExportReference)
   --- End of inner exception stack trace ---
   at Xamarin.Android.Tasks.Generator.CreateJavaSources(List`1 javaTypes, String outputPath, Boolean useSharedRuntime, Boolean hasExportReference)
   at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__1c.MoveNext()	C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets	686	3	Cirrious.Conference.UI.
Comment 6 Stuart Lodge 2012-05-25 12:20:34 UTC
I'm not sure what the problem is here, but the inheritance tree it quite involved and there are portable class library assemblies at the root of the tree.

The class hierarchy and split between Assemblies is:

Cirrious.MvvmCross.Droid.Maps.dll contains MvxBindingMapActivityView<TViewModel>

This inherits from:

        : MvxMapActivityView<TViewModel>
        , IMvxBindingActivity


MvxMapActivityView<TViewModel> is also in Cirrious.MvvmCross.Droid.Maps.dll - it inherits from 

        : MapActivity
        , IMvxAndroidView<TViewModel>

where MapActivity is in the Mono4Droid Maps assembly, and IMvxAndroidView is in the Cirrious.MvvmCross.Droid.dll assembly


IMvxBindingActivity is in the Cirrious.MvvmCross.Binding.Droid assembly.


I've tried to repro the problem in a simpler test solution (including a PLP/PCL just for fun) and can't get it reproduced.

Will continue....
Comment 7 Stuart Lodge 2012-05-25 12:27:37 UTC
Using the debug tasks dll from above gives the same debug info.... Thanks for including the extra info in 4.2.2
Comment 8 Stuart Lodge 2012-05-25 12:36:53 UTC
OK... it's official - I'm guilty.

The problem it seems was down to a dangling reference to an old assembly from before I did the portable class library refactoring and renaming - to Cirrious.MvvmCross.Android.Maps - see screengrab at http://i.imgur.com/chtO1.png

Because the project no longer existed on disk, then doing a clean all and rebuild did nothing to the .dll in the debug folder - it just stayed there.

And then the linker problem occurred because it was built with an old copy of Mono4Android. So the problem here was not that the assembly wasn't referenced - it was that an old assembly version was referenced?

Sorry for taking up so much time on this one. Thanks for the extra debug output for GenerateJavaTasks.

Stuart
Comment 9 Jonathan Pobst 2012-05-25 12:39:01 UTC
No problem, we definitely needed to improve that error message so people have a place to start digging!

Glad you figured it out!