Bug 5618 - Mono.Android.Export.dll should be found via implicit
Summary: Mono.Android.Export.dll should be found via implicit
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.2.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Atsushi Eno
Depends on:
Reported: 2012-06-12 14:42 UTC by Jonathan Pryor
Modified: 2012-12-01 06:09 UTC (History)
2 users (show)

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

Scratch.IndirectExport.zip (17.38 KB, application/zip)
2012-06-12 14:42 UTC, Jonathan Pryor

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 Jonathan Pryor 2012-06-12 14:42:19 UTC
Created attachment 2043 [details]

#5151 changed the fast deployment model so that assemblies could be found implicitly, instead of requiring that every assembly to be deployed also be referenced by the App project.

The problem is that Mono.Android.Export.dll doesn't support this new model; if we have an App project which references a Library project, and the Library project references Mono.Android.Export.dll, the App fails to build.

monodroid email thread:

To reproduce, build the attached project.

Expected result: it builds.

Actual results:
Failed to create JavaTypeInfo for class: Library.JavascriptInterface ---> System.InvalidOperationException: You need to add a reference to Mono.Android.Export.dll when you use ExportAttribute or ExportFieldAttribute.
Comment 1 Atsushi Eno 2012-06-20 04:18:24 UTC
Instead of the expected error, I'm rather got this one:

	/home/atsushi/svn/monodroid/tools/msbuild/build/Novell/Novell.MonoDroid.Common.targets: error : Error executing task GenerateJavaStubs: Failed to create JavaTypeInfo for class: Library.JavascriptInterface

Isn't this due to different issue?
Comment 2 Jonathan Pryor 2012-06-20 10:18:02 UTC
I'm not sure why you're getting that error. /verbosity:diagnostic output might be helpful.

I created the project by adding the Mono.Android.Export.dll assembly reference to the Application and Library projects, making sure it all built and ran, then just removing the Mono.Android.Export.dll assembly reference from the Application project.

Re-adding the Mono.Android.Export.dll assembly reference to the Application project _should_ allow it to build. (At least, it built when I first created the project...)
Comment 3 Atsushi Eno 2012-07-02 04:44:29 UTC
OK, that error *is* wrapping the missing export error as InnerException.

Now, I implemented decent assembly ref lookup, but noticed that there is another problem:

atsushi@atsushi-Aspire-3820:~/Desktop/Scratch.IndirectExport/Library/bin/Debug$ monodis --assemblyref Library.dll
AssemblyRef Table
1: Version=
	Public Key:
0x00000000: C4 C4 23 75 47 E4 B6 CD 
2: Version=
	Public Key:
0x00000000: 7C EC 85 D7 BE A7 79 8E 

There is somehow no reference to Mono.Android.Export.dll which makes it impossible to find the dll.
Comment 4 Atsushi Eno 2012-07-02 04:51:32 UTC
OK, this bug is invalid. No matter whether you add a reference to Mono.Android.Export.dll or not, the resulting assembly won't contain the reference because it is not in use at all (note that Java.Interop.ExportAttribute resides in Mono.Android.dll).

The only way you can add reference to Mono.Android.Export.dll is in the application, unless you explicitly use the types in this assembly.
Comment 5 Atsushi Eno 2012-07-02 04:54:07 UTC
I can still make changes to msbuild to look for indirect references, but it is meaningless, because none of the users can actually use the types in Mono.Android.Export.dll (there is no public type in it).
Comment 6 Jonathan Pryor 2012-07-02 10:48:15 UTC
I suppose this is why I wanted Java.Interop.ExportAttribute to be in Mono.Android.Export.dll... ;-)

Le sigh...
Comment 7 Máté Rédecsi 2012-11-30 08:37:39 UTC
The same issue happened when I tried to build my app with the linking option "Sdk and User Assemblies". With the solution attached can reproduce what I'm talking about.

Please, can you help me to solve this? It's important in my application to use the mentioned option.
Comment 8 Atsushi Eno 2012-11-30 08:49:30 UTC
I have no idea what you meant by "the mentioned option" but you could (and need to) add Mono.Android.Export.dll to your application project.
Comment 9 Máté Rédecsi 2012-11-30 08:59:54 UTC
I did. And it works fine until the linker option isn't set to "sdk and user assemblies" in project properties.
Comment 10 Jonathan Pryor 2012-11-30 14:54:43 UTC
Please, DO NOT use "Link SDK and User assemblies."

Use "Link SDK Assemblies."
Comment 11 Máté Rédecsi 2012-11-30 15:27:50 UTC
When I use "Link SDK Assemblies." my application stops without any exception. I thought it's because some of my own libraries couldn't be used without linking it... That's the cause of using "Link SDK and User assemblies."
Comment 12 Jonathan Pryor 2012-11-30 15:41:18 UTC
Please file a separate bug about the application death without exception, and attach your project.
Comment 13 Máté Rédecsi 2012-12-01 06:09:40 UTC
Unfortunately I can't. It's a huge project, and I develop it to a company so the source code is private. What's the problem with using "Link Sdk and User assemblies"? And why can't be solved the problem with this option and Export dll?