Skip to content Skip to sidebar Skip to footer

Plugin Cannot Be Resolved To A Type Issue- Cordova-2.7.0

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?

Solution 1:

I found that in Cordova 3.0 you have to also remove "api" from the import statement.

Change

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

To this:

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.PluginResult;

Solution 2:

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:

publicclassPingPluginextendsPlugin {

to:

publicclassPingPluginextendsCordovaPlugin {

Change:

publicPluginResultexecute(String action, JSONArray args, String callbackId) {

to:

publicbooleanexecute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

Change failed results such as:

returnnew PluginResult(PluginResult.Status.ERROR, e.getMessage());

to something like:

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

Change success results such as:

returnnewPluginResult(PluginResult.Status.OK);

to something like:

callbackContext.success();
returntrue;

Post a Comment for "Plugin Cannot Be Resolved To A Type Issue- Cordova-2.7.0"