I am trying to make a simple cordova android plugin that requires classes defined in a jar file. I have a test project here, that includes the example usage & a simplified version of my plugin.
In my plugin.xml, I have this:
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Pebble">
<param name="android-package" value="com.jetboystudio.pebble.PebblePGPlugin"/>
</feature>
</config-file>
<source-file src="src/android/PebblePGPlugin.java" target-dir="src/com/jetboystudio/pebble" />
<source-file src="src/android/libs/pebble_kit.jar" target-dir="libs" />
</platform>
In my test project, I have pebblekit jar in-place where it needs to be (I think): plugins/com.jetboystudio.pebble.PebblePGPlugin/src/android/libs/pebble_kit.jar
When I "cordova build" I get no errors, but when I install the apk-file I get "Class not found" in Chrome device inspect. I am assuming this class it can't find is one of the classes defined in pebble_kit.jar. Also, it doesn't seem to be copying this file into platforms/android.
If I could just debug better (which class is not found?) that might be a good start, if no one has the actual answer of why this doesn't work.
A plugin is most commonly a Java Jar file that contains a set of resource files (e.g., color tables) and/or Java class files.
Open the plugin project in your IDE. After that add the third-party jars to the Java classpath. In IDE, click Project Structure/Modules/Select pluginName_android / Dependencies tab/Green PlusSign/jars or directories. Later select the individual jars or the whole folder.
Plugin APIs camera: This plugin is used to provide an interface to enable the device camera. It can also select the images from the device storage. contacts: It allows access to the device contacts. device: It provides an interface to retrieve the information about the hardware and software.
Your plugin.xml
is correct.
Do not edit the plugin.xml
after you have added/install the plugin into the project.
When you run cordova build or prepare it will not process the native parts of plugin.xml, it only get's process on cordova plugin add
Update your plugin repo/folder with plugin.xml
containing the jar file and the line that you have is correct.
Then do
cordova plugin rm
cordova plugin add
cordova build
The end result verify that /platforms/android/libs/pebble_kit.jar
is present after cordova build.
You can also add a jar file with:
<lib-file src="src/android/libs/pebble_kit.jar" />
This will add the jar to platforms/android/app/libs/
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