Binding .JAR / using JNI

I'm trying to create a binding for Aspose.Words for Android. I'm following the guide at:

https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/

Unfortunately I'm getting all kinds of errors related to obfuscation.

e.g.

1>JARTOXML : warning J2XA006: missing class error was raised while reflecting com.aspose.words.zzDZ : asposewobfuscated/zzW8

I've got over 1,000 of these, so it's not just a matter of a few tweaks to the XML.

I'm thinking then that I need to consider this:

https://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/working_with_jni/

But I can't for the life of me find anything that tells me how to get the .JAR into my project, then invoke a method. All the examples seem to talk about the native methods that are already built-in.

Can anyone tell me what I'm missing here?

Best Answer

  • PeterMillsPeterMills GB ✭✭
    Accepted Answer

    In the end I had to write a Java assembly that wrapped up each of the method calls - this meant the obfuscation wasn't a problem anymore.

Answers

  • PeterMillsPeterMills GBMember ✭✭

    I forgot to add, after all the warnings. I get this:

    1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.targets(380,5): error MSB6006: "generator.exe" exited with code -1073741819.

  • PeterMillsPeterMills GBMember ✭✭

    Having turned MSBUILD verbosity up, I get:

    1>BINDINGSGENERATOR : warning BG8103: Class Com.Aspose.Words.HeaderFooterCollection has invalid base type com.aspose.words.NodeCollection.
    1> (TaskId:38)
    1> Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. (TaskId:38)
    1> at MonoDroid.Generation.ReturnValue.get_JavaName() (TaskId:38)
    1> at MonoDroid.Generation.Method.get_IsVoid() (TaskId:38)
    1> at MonoDroid.Generation.Method.get_CanGet() (TaskId:38)
    1> at MonoDroid.Generation.Method.get_IsPropertyAccessor() (TaskId:38)
    1> at MonoDroid.Generation.GenBase.AddPropertyAccessors() (TaskId:38)
    1> at MonoDroid.Generation.GenBase.FillProperties() (TaskId:38)
    1> at MonoDroid.Generation.GenBase.FillProperties() (TaskId:38)
    1> at Xamarin.Android.Binder.CodeGenerator.Run(CodeGeneratorOptions options) (TaskId:38)
    1> at Xamarin.Android.Binder.CodeGenerator.Main(String[] args) (TaskId:38)
    1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.targets(380,5): error MSB6006: "generator.exe" exited with code -1073741819.
    1>Done executing task "BindingsGenerator" -- FAILED. (TaskId:38)

    It would appear something in the code generator is upset with Aspose. Can I get this raised?

  • trinnguyentrinnguyen VNMember ✭✭

    Have you added permission Camera to AndroidManifest.xml?

  • trinnguyentrinnguyen VNMember ✭✭

    My mistake on typing. Should be Internet permission.
    Xamarin.Android app can access internet in the Debug mode, but will need this permission in Release (also the real world).

  • PeterMillsPeterMills GBMember ✭✭
    Accepted Answer

    In the end I had to write a Java assembly that wrapped up each of the method calls - this meant the obfuscation wasn't a problem anymore.

Sign In or Register to comment.