Reputation: 3493
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.
Upvotes: 17
Views: 14464
Reputation: 1441
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/
Upvotes: 4
Reputation: 5022
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.
Upvotes: 14