Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including .jar file into cordova plugin

I need to include 3rd party plugin .jar to my custom cordova plugin. I can't find any way to do this.

f.e. some of my actual code looks like this (in plugin.xml):

<platform name="android">
        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="AztecReader">
                <param name="android-package" value="com.example.aztecreadermobilas.AztecReaderPlugin"/>
            </feature>
        </config-file>

        <source-file src="src/android/AztecReaderPlugin.java" target-dir="src/com/example/aztecreadermobilas" />      
</platform>  

Libraries I need to include:

/libs
    /armeabi
        /libAztecLibrary.so
    /armeabi_v2
        /libAzteclibraryv2.so
    /AztecReader.jar
like image 717
Tomasz Kasperek Avatar asked Sep 30 '22 19:09

Tomasz Kasperek


1 Answers

I found an example potentially covering your use case:

https://github.com/phonegap/phonegap-plugin-fast-canvas/blob/master/plugin.xml

Have a look at line 31. It seems that precompiled libraries (in this case Android/libs/armeabi/libFastCanvasJNI.so) may be included via source-file directive.

I don't know if this will work for java class files as well. You may accomplish this by extracting the jar and adding each contained class file as source-file. Just have a try.

AztecReader seems to be available as source code, so you could at the sources (java files) directly to your plugin. They will be compiled during app build. This seems to be the obviously easiest way to integrate the reader in your plugin.

like image 64
regnete Avatar answered Oct 03 '22 00:10

regnete