Java Binding Projects - High level questions..

A couple of questions here, thanks to anyone who has some time to help!

1) In the .aar binding walkthrough HERE it says that you can only have 1 .aar per project. Meaning if I have 4 .aars to port, that they each have to be in their own independent project. Is that correct?

2a) If I have an .aar that I need ported and accessible through C#, but lets say that .aar has 2 or 3 other dependencies which are not available through nuget, etc... (assume the dependencies are a mix of .jars and .aars). That means I have to port the dependencies as well correct?

2b) I don't technically care about the C# implementation of them, I just need them to support the primary package.. if I'm hitting errors thrown on the generated code from those "transitive dependencies", how can I handle that if I don't _directly _need access to the APIs? Would be great if I could just tell the build system "don't expose these" externally.

3) Lastly, one of the errors that still eludes me was one that VS threw from one of the generated .cs files. After building the project in question, I had an error that said something like "Parameter '__result' does not exist in the current context." at file: [rootBindingDir]\obj\Debug\generated\src\SomeBaseClass.cs.

The issue is that error was being thrown from a BASE class. Meaning it was overridden in each implementing class, therefore obstructing my ability to access it through the Metadata file (the base method didn't have a signature generated in the api.xml file). The non-base class overrides were exposed, but not the base method. How are we supposed to fix issues like that?

Sorry if this was long, please don't feel obligated to respond to them all, any help is appreciated! This is probably the most complex subject I've come up against in Xamarin. So much so, that I'm contemplating creating a blog and answering issues like this as my first few posts...

Best Answer

  • LanceKingLanceKing US ✭✭
    edited August 2017 Accepted Answer

    More updates:

    1) My best understanding of this question is now yes, .aar's should each have their own project, and after they've been built successfully, should be referenced by the primary project you're trying to get access from C# to.

    3) Still not fully sure how to rectify this issue, but what I ended up doing was adding a "remove-node" directive in the Metadata.xml file to remove the entire base class that was throwing the C# error. This obviously caused numerous other warnings (not errors though), BUT it allowed the project to at least successfully build the DLL, which is all I cared about.

    SOME HELPFUL NOTES:

    From what I now understand (please anyone correct me if I'm wrong):

    Creating and building a Java Bindings Library, generates C# wrappers around (somewhat difficult to understand) calls to native Java methods, properties, classes, etc. Therefore the whole point to this process is simply to gain access to native .jars and .aars, within your C# code. But here's the kicker, you really only care about those endpoints that you plan on utilizing. So, just because the project throws warnings about missing references or types, doesn't necessarily mean the project wont work for you.

    Your main goal here is simple. Get the projects set up so that they will output a DLL. Even if there are 100's of warnings, as long as those warnings don't impede the project's ability to output the DLL, OR affect the methods, properties, or classes you will be calling directly from C#, you likely don't need to worry about them.

    It's that simple. I hate errors and warnings too, but in this situation they're not nearly as important as you may think.

    Feel free to message me here if anyone has simple issues I can help with. I'd be happy to at least point you in the right direction.

Answers

  • LanceKingLanceKing USMember ✭✭
    edited August 2017

    Looks like I found an answer to some of these questions in the guides. I must have missed them, so I'll start answering my own questions in hopes that it helps others!

    2a and 2b) The transitive dependencies must be referenced (still not sure yet if they can be in the same project or not in the case of .aars), but they should be set as ReferenceJar's in the properties, and this will ensure that bindings don't get generated for them. Here's the guide info on that.

    ( @NashZhou here's the new thread )

  • LanceKingLanceKing USMember ✭✭
    edited August 2017 Accepted Answer

    More updates:

    1) My best understanding of this question is now yes, .aar's should each have their own project, and after they've been built successfully, should be referenced by the primary project you're trying to get access from C# to.

    3) Still not fully sure how to rectify this issue, but what I ended up doing was adding a "remove-node" directive in the Metadata.xml file to remove the entire base class that was throwing the C# error. This obviously caused numerous other warnings (not errors though), BUT it allowed the project to at least successfully build the DLL, which is all I cared about.

    SOME HELPFUL NOTES:

    From what I now understand (please anyone correct me if I'm wrong):

    Creating and building a Java Bindings Library, generates C# wrappers around (somewhat difficult to understand) calls to native Java methods, properties, classes, etc. Therefore the whole point to this process is simply to gain access to native .jars and .aars, within your C# code. But here's the kicker, you really only care about those endpoints that you plan on utilizing. So, just because the project throws warnings about missing references or types, doesn't necessarily mean the project wont work for you.

    Your main goal here is simple. Get the projects set up so that they will output a DLL. Even if there are 100's of warnings, as long as those warnings don't impede the project's ability to output the DLL, OR affect the methods, properties, or classes you will be calling directly from C#, you likely don't need to worry about them.

    It's that simple. I hate errors and warnings too, but in this situation they're not nearly as important as you may think.

    Feel free to message me here if anyone has simple issues I can help with. I'd be happy to at least point you in the right direction.

Sign In or Register to comment.