I followed the recipe at http://docs.xamarin.com/android/tutorials/Binding_a_Java_Library_(.jar)#Adding_the_Google_Maps_Java_Library for creating a .NET wrapper around a java library. I can compiled the Java Bindings project with no errors. However, when I reference the project from an Android application project, I cannot see any of the namespaces, classes, or other members of the Java Bindings project.
If you download the sample code given in the article (http://docs.xamarin.com/@api/deki/files/2825/=MyGoogleMaps-MD.zip), and try to reference the "MyGoogleMaps" library, you will see the same problem.
I tried the latest alpha of Mono for Android and it didn't seem to help.
You can work around this by using a dll reference instead of a project reference.
*** This bug has been marked as a duplicate of bug 5966 ***
I tried that and got the same result.
BTW, I can't access the original bug you linked - is it private?
*** Bug 5966 has been marked as a duplicate of this bug. ***
Yes, it is, unfortunately the initial filing of that bug included an attachment that needs to be kept private. We'd been keeping it as the primary bug because it has some extensive discussions about how to solve this in the comments, however it couldn't be tracked in public, which is a problem.
I've now marked it as a dup of this bug - we'll have to refer to that one for the older discussions.
Here is some explanation copy-pasted from the earlier bug:
The reason the types are unresolved in unresolved in the syntax highlighting and in code completion is a consequence of the way that the Android binding projects work - they generate the binding source code at compile time and inject it into the build. So it's simply not available to the C# parser.
The reason the workaround works is that when it's changed from a project reference to a dll reference, parses the dll instead of the source code. However, that's an imperfect solution - it won't work unless the binding dll has already been built, not will it pick up changes until the binding project is rebuilt.
One possible fix would be to change binding projects so that the generated code is part of the project, maybe as "children" (dependent files) of the jar file. The project would have to run the jar processing MSBuild target when adding or updating the jar file. This would be very similar to what we do with the Resource.designer.cs file.
Any other fixes would be much, much more difficult. For example, implementing a code completion parser for jar files that would parse them directly into MD's type system, which would be a duplication of all the binding generation code.
Using the dll parser instead of the C# parser for java binding projects is an option, but it would have the same issues as dll references.
Thanks for pasting that info; I went back and looked at my project. I can build my project just fine - it's only intellisense that's missing. My earlier comment about the DLL reference (and project reference) is incorrect.
It's strange I don't get any intellisense with a DLL reference though - any thoughts?
No idea. Can you send us the project so we can take a look? You can attach it and mark it private or send it to firstname.lastname@example.org.
Created attachment 2417 [details]
A java bindings library project and a sample applicatin
The AWSDynamoBinding project binds some Amazon java libraries. The HelloAndroid project references the AWSDynamoBinding project. Activity1.cs refers to a class from AWSDynamoBinding (private static Com.Amazonaws.Services.Dynamodb.Model.Condition foo); the project will compile, but intellisense does not see any classes or types exported from the AWSDynamoBinding project.
Completion now works after compiling the binding project.
*** Bug 6756 has been marked as a duplicate of this bug. ***
What build of MonoDevelop will this fix land in? Is it already availabe on the alpha or beta channels?
In 3.1.x - it's atm not available, but we're working on it.
We need to backport these to the stable series, since the upcoming 4.0 wont be out until January or so.
Did this get backported to 3.0, along with issue 6719 - https://bugzilla.xamarin.com/show_bug.cgi?id=6719 ?
Y it did
Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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.
Create a new report for Bug 6695 on Developer
Community or GitHub if you have new information to add and do not yet see a matching
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
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.