I'm trying to generate a Xamarin Binding for Android com.adobe.creativesdk.image library
The problem is that this library contains like 20 references and these references for sure contains much more. I'd have to explore the entire tree and extract all references to add them to the binding project.
For sure there must be an easier way to do this. I was told that I could create a bundle AAR that includes all references using Android Studio but I'm not certain about steps to make it work. Some of the references are AAR too.
Could you please put me in the correct path to get this binding working?
Binding libraries always have their own Caveats, but I'm going to do some generalization to help keep you organized.
Check the dependencies involved and if any of them are already on Nuget USE THOSE. Things like Android Support Libraries, Google Play APIs, IBM SDKs, etc. Most of them already have bindings and are in Nuget.
Don't forget to check your dependencies version numbers against the ones in Nuget. Maybe your .aar lib is actually more up to date than the Binding on Nuget.
Separate big libraries. Find the rest of your dependencies that are not in Nuget that are relatively large, then create separate Android Binding Library Projects for each of them. Commonly the Binding APIs will fall apart with large libraries as dependencies, so it is far easier (and cleaner IMO) to create separate projects for them, then add project references to your end library.
Separate your jars
from aars
. Usually your .aar
files are the big ones that get their own bindings anyway and loop into #3, but jar
dependencies should use ReferenceJar
Build Actions.
Play with your MetaData.xml
. This can take a long time, but the Binding APIs aren't perfect. Use the MetaData
and other files to get it cleaned to your liking.
Some other things that might help:
.jar
and .aar
files into your Jars
folder since this adds them to the project root for some reason)MetaData.xml
file)I had the same issue, and i finally solved it by simply adding the dependencies. Many can be added via the NuGet packages (rightclick on bindingproject and click add nuget packages...), the most common ones like play services, gson okhttp3 etc. can be found here. If you, like me, had some more uncommon dependencies, you might need to add them as bindingprojects themselves.
I read that you could add the aar/jar dependency to the bindingproject directly, and set build action to referenceJar or embeddedReferenceJar, but this did not work for me. Im relatively new to xamarin so im not sure if its just not the way its intended to be used or if it was because they could not automatically be bound due to execution error (got some errors and warnings that i needed to fix in the metafile when i later added the dependency jar/aar into its own bindingsproject).
Regardless, the way i got it to work was by adding a new bindingsproject to the solution, in which i added the dependency jar/aar and then built it and added the needed rows/nodes in the metafile to make it compile. Then i simply added the "dependency-binding" project as a reference in my actual bindingsproject.
This feels more like a workaround than an actual solution, but atleast i got it to work, so hopefully it can help you.
Heads up for anyone which needs to create a wrapper around an aar/jar java dependency to make it play nice with C#. You are best referencing the aar dependency through a binding dll than trying to add it into the same binding, xamarin cannot use more than one aar per binding. Write the wrapper in it's own aar/binding, and have the wrapper binding/dll reference the dependency also as a binding/dll. Also - you're better using an aar file than a jar, jar seems to be kind of deprecated these days.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With