Bug 6695 - Unable to use "Java Bindings Library"
Summary: Unable to use "Java Bindings Library"
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Android Add-in (show other bugs)
Version: 3.0.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Mike Krüger
URL:
: 5966 6756 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-08-26 21:26 UTC by Justin
Modified: 2012-11-20 03:21 UTC (History)
6 users (show)

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


Attachments
A java bindings library project and a sample applicatin (4.39 MB, application/octet-stream)
2012-08-27 13:18 UTC, Justin
Details

Description Justin 2012-08-26 21:26:55 UTC
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.
Comment 1 Mikayla Hutchinson [MSFT] 2012-08-27 10:57:21 UTC
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 ***
Comment 2 Justin 2012-08-27 11:24:13 UTC
I tried that and got the same result.

BTW, I can't access the original bug you linked - is it private?
Comment 3 Mikayla Hutchinson [MSFT] 2012-08-27 12:13:26 UTC
*** Bug 5966 has been marked as a duplicate of this bug. ***
Comment 4 Mikayla Hutchinson [MSFT] 2012-08-27 12:16:07 UTC
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.
Comment 5 Mikayla Hutchinson [MSFT] 2012-08-27 12:24:19 UTC
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.
Comment 6 Justin 2012-08-27 12:35:22 UTC
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?
Comment 7 Mikayla Hutchinson [MSFT] 2012-08-27 12:51:15 UTC
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 support@xamarin.com.
Comment 8 Justin 2012-08-27 13:18:49 UTC
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.
Comment 13 Mike Krüger 2012-08-29 05:56:50 UTC
implemented.

Completion now works after compiling the binding project.
Comment 14 Mikayla Hutchinson [MSFT] 2012-08-31 11:56:21 UTC
*** Bug 6756 has been marked as a duplicate of this bug. ***
Comment 15 Justin 2012-09-04 12:23:41 UTC
What build of MonoDevelop will this fix land in? Is it already availabe on the alpha or beta channels?
Comment 16 Mike Krüger 2012-09-05 01:11:46 UTC
In 3.1.x - it's atm not available, but we're working on it.
Comment 17 Miguel de Icaza [MSFT] 2012-10-13 10:48:15 UTC
We need to backport these to the stable series, since the upcoming 4.0 wont be out until January or so.
Comment 18 Chris Hardy [MSFT] 2012-11-16 06:36:15 UTC
Did this get backported to 3.0, along with issue 6719 - https://bugzilla.xamarin.com/show_bug.cgi?id=6719 ?
Comment 19 Mike Krüger 2012-11-20 03:21:49 UTC
Y it did

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.


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 report.

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

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.

Related Links: