Including .jar file in cordova plugin

I need to include a third party plugin .jar

in my own cordova plugin. I cannot find a way to do this.

fe 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 to include:

/libs
    /armeabi
        /libAztecLibrary.so
    /armeabi_v2
        /libAzteclibraryv2.so
    /AztecReader.jar

      

+3


source to share


2 answers


I found an example potentially covering your use case:

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

Look at line 31. It seems that the pre-copied libraries (in this case Android / libs / armeabi / libFastCanvasJNI.so) might be included in the source file directive.



I don't know if this will work for java class files. You can accomplish this by extracting the jar and adding each class file it contains as a source file. Just try it.

AztecReader seems to be available as source code, so you can in sources (java files) link directly to your plugin. They will be compiled during application build. This seems to be the easiest way to integrate a reader into your plugin.

+4


source


The .so.jar file is the same as the .java file, just use:

<source-file src="path/to/foo.so" target-dir="libs/" />



tips: yourApp / platform / android / is android project dir, after creating android corova, you can debug it in Android Studio as usual. What a bore, every time you change the plugin code, you have to remove and re-add it.

0


source







All Articles