I’m trying to write a plugin for cordova and I keep getting this error message when I try and interact with it on an android device.
Here is my Java code, which I have simplified.
package paypalhere;
//Lots of imports
public class paypalhereWrapper extends CordovaPlugin implements CardReaderConnectionListener, AuthenticationListener, TransactionController {
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if (action.equals("coolMethod")) {
String message = args.getString(0);
this.coolMethod(message, callbackContext);
return true;
}
else if (action.equals("IntPPSDK")) {
String token = args.getString(0);
this.IntPPSDK(token);
return true;
}
return false;
}
private void coolMethod(String message, CallbackContext callbackContext) {
if (message != null && message.length() > 0) {
callbackContext.success(message);
} else {
callbackContext.error("Expected one non-empty string argument.");
}
}
private void IntPPSDK(String compositeAccessToken) {
//stuff
}
//Stuff in here
}
Here is my Javascript interface wrapper
var exec = require('cordova/exec');
window.coolMethod = function (arg0, success, error) {
console.log("coolMethod Called");
exec(success,
error,
"paypalhere.paypalhereWrapper",
"coolMethod",
[arg0]);
};
window.IntPPSDK = function (token) {
console.log("IntPPSDK Called");
exec(function () {
console.log("IntPPSDK Sucess");
},
function (x) {
console.log("IntPPSDK Error - " + x.toString());
},
"paypalhere.paypalhereWrapper",
"IntPPSDK",
[token]);
}
And here is my plugin.xml
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-paypal-here" version="0.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-paypal-here</name>
<js-module name="paypalhere" src="www/paypalhere.js">
<clobbers target="window.paypalhere" />
</js-module>
<platform name="android">
<config-file parent="/*" target="res/xml/config.xml">
<feature name="paypalhere">
<param name="android-package" value="paypalhere" />
</feature>
</config-file>
<config-file parent="/*" target="AndroidManifest.xml" />
<source-file src="src/android/paypalhereWrapper.java" target-dir="src/paypalhere" />
<source-file src="src/android/paypalhereCallbacks.java" target-dir="src/paypalhere" />
<framework src="src/android/paypalhere.gradle" custom="true" type="gradleReference" />
<resource-file src="aar/PayPalHereSDK.aar" target="aar/PayPalHereSDK.aar" />
</platform>
<platform name="ios">
<config-file parent="/*" target="config.xml">
<feature name="cordova-plugin-paypal-here">
<param name="ios-package" value="cordova-plugin-paypal-here" />
</feature>
</config-file>
<source-file src="src/ios/cordova-plugin-paypal-here.m" />
</platform>
</plugin>
Does anyone have any idea why would I be getting a class not found error? I have tried changing around some of the values in the plugin.xml file but nothing seems to work.