Plugin cannot be resolved to a type issue- cordova-2.7.0

后端 未结 2 1276
执笔经年
执笔经年 2021-01-07 09:14

I have added Cordova-2.7.0.jar file and js file in the PhoneGap application given in this link. But now i\'m getting this error. How to solve this error?

<
2条回答
  •  再見小時候
    2021-01-07 09:33

    You need to update the plugin architecture (see here), something like this:

    Replace:

    import org.apache.cordova.api.Plugin;
    import org.apache.cordova.api.PluginResult;
    import org.apache.cordova.api.PluginResult.Status;
    

    with:

    import org.apache.cordova.api.CallbackContext;
    import org.apache.cordova.api.CordovaPlugin;
    

    Change:

    public class PingPlugin extends Plugin {
    

    to:

    public class PingPlugin extends CordovaPlugin {
    

    Change:

    public PluginResult execute(String action, JSONArray args, String callbackId) {
    

    to:

    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    

    Change failed results such as:

    return new PluginResult(PluginResult.Status.ERROR, e.getMessage());
    

    to something like:

    LOG.e("PingPlugin", "Error : " + e.getMessage());
    return false;
    

    Change success results such as:

    return new PluginResult(PluginResult.Status.OK);
    

    to something like:

    callbackContext.success();
    return true;
    

提交回复
热议问题