Bug 11051 - Wrong Service Attribute throws ApplicationException on generateJavaStubs
Summary: Wrong Service Attribute throws ApplicationException on generateJavaStubs
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.8.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2013-03-11 16:07 UTC by Juan Manuel
Modified: 2017-07-06 18:24 UTC (History)
3 users (show)

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

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:

Description Juan Manuel 2013-03-11 16:07:26 UTC
I managed to find the problem.
I created a service and added the Service Attribute the wrong way.
I was adding this:

[Service(Name="SomeName")] and found it mus t be [Service] only.

Instead of giving a compile error informing where the problem is as it should be, it throws and exepciont of type ApplicationException on the step GenerateJavaStubs.

Here I copy the exception, but it's in spanish (since that's my language).

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(3,3): Error MSB4018: Error inesperado en la tarea "GenerateJavaStubs".

System.ApplicationException: Failed to create JavaTypeInfo for class: com.harkdev.ServerStatus.ServerStatusCheckService ---> System.InvalidOperationException: The Name property must be a fully qualified 'package.TypeName' value, and no package was found for 'ServerStatusCheckService'.

   en Xamarin.Android.Tasks.JavaTypeInfo..ctor(TypeDefinition type, String outerType)

   en Xamarin.Android.Tasks.Generator.CreateJavaSources(List`1 javaTypes, String outputPath, Boolean useSharedRuntime, Boolean hasExportReference)

   --- Fin del seguimiento de la pila de la excepción interna ---

   en Xamarin.Android.Tasks.Generator.CreateJavaSources(List`1 javaTypes, String outputPath, Boolean useSharedRuntime, Boolean hasExportReference)

   en Xamarin.Android.Tasks.GenerateJavaStubs.Execute()

   en Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

   en Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() (MSB4018) (com.harkdev.ServerStatus)
Comment 1 Sebastien Pouliot 2013-05-21 15:56:50 UTC
-> Xamarin.Android
Comment 2 Jonathan Pryor 2013-05-23 22:35:09 UTC
The problem here is that we process the compiled IL to generate the Java code, so by the time GenerateJavaStubs executes we can't trivially determine the file + line number, which would be _really_ _handy_ for this bug.

TODO: see if there's a way to use the Debug symbols (.pdb, .dll.mdb) to determine the declaration location of the custom attribute, and provide that in the error message.

This bug is _partially_ ameliorated with master/68975a04, which will provide Proper MSBuild error messages (though without file+line number), instead of showing an unhandled exception.
Comment 3 Cody Beyer (MSFT) 2017-07-06 18:24:42 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Android. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.