Bug 12504 - Broken type binding error message is not actionable
Summary: Broken type binding error message is not actionable
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.7.x
Hardware: PC Mac OS
: --- normal
Target Milestone: 4.8 (async)
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-05-31 18:54 UTC by Rodrigo Kumpera
Modified: 2013-06-28 14:10 UTC (History)
3 users (show)

Tags:
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:
Status:
VERIFIED FIXED

Description Rodrigo Kumpera 2013-05-31 18:54:07 UTC
If I have this class on my project and I don't reference Mono.Android.Export.dll I get a non actionable error message.

Class:

	public class Parcelable<T> :Java.Lang.Object
	{
		[ExportField("STUFF")] public static void Stuff()
		{

		}

	}

Error message:

	/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Error executing task GenerateJavaStubs: Failed to create JavaTypeInfo for class: AndroidGenerics.Parcelable`1


If I run xbuild with  /verbosity:diagnostic I get what I need, but this is not usable by regular users:

Error executing task GenerateJavaStubs: System.ApplicationException: Failed to create JavaTypeInfo for class: AndroidGenerics.Parcelable`1 ---> System.InvalidOperationException: You need to add a reference to Mono.Android.Export.dll when you use ExportAttribute or ExportFieldAttribute.


Going further, XS Errors pad gets it completely work. It shows the erros message and point the broken file to be  Xamarin.Android.Common.Target. Double clicking it is extremely confusing.

Finally, if I try to edit the opened file and save I get a cryptic XS exception due to:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.UnauthorizedAccessException: Access to the path "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/.#Xamarin.Android.Common.targets" is denied.
Comment 2 Jonathan Pryor 2013-06-24 17:34:32 UTC
This was fixed in monodroid/7f6dfe69 as part of the fix for Bug #10135, and will now generate XA4207 ("[ExportField] cannot be used on a generic type") and (possibly) XA4208, "[ExportField] cannot be used on a method returning void.".
Comment 3 Jonathan Pryor 2013-06-24 17:37:26 UTC
Sorry; I misread the bug, and Comment #2 does not apply.
Comment 4 Jonathan Pryor 2013-06-24 17:39:00 UTC
This was fixed in monodroid/b692b221, and will now generate error XA4210 "You need to add a reference to Mono.Android.Export.dll when you use ExportAttribute or ExportFieldAttribute."
Comment 5 Saurabh 2013-06-28 13:44:14 UTC
Today we have checked this issue on following builds :

XS 4.0.9 (build 12)
X.Android 4.7.11002

When we run the given code in XS then we get error message as given in comment 2. But we are still not able to get error message as in comment 4.

Please suggest us how to get error message as per comment 4 to verify this issue.
Comment 6 Jonathan Pryor 2013-06-28 13:59:08 UTC
@Saurabh: XA4210 is generated at package creation time. Thus:

1. Create a new project.
2. Add a new method which uses [Export], e.g.

    [Java.Interop.Export] void Foo () {}

3. Build. This will succeed w/o error.
4. Install the project onto a device.

(4) should fail with XA4210.
Comment 7 Saurabh 2013-06-28 14:10:37 UTC
Thanks Jonathan.

Now we are getting expected result as per comment 6 with following builds :
XS 4.0.9 (build 12)
X.Android 4.7.11002
 
Hence closing this issue. Changing its status to verified.