插件无法解析为类型issue- cordova-2.7.0 [英] Plugin cannot be resolved to a type issue- cordova-2.7.0

查看:193
本文介绍了插件无法解析为类型issue- cordova-2.7.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在),类似这样:



替换:

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

其中:

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

更改:

 code> public class PingPlugin extends Plugin {

至:



public class PingPlugin extends CordovaPlugin {

Change:

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



到:

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

更改失败的结果,例如:

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

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

更改成功结果,例如:

  return new PluginResult(PluginResult.Status.OK); 

  callbackContext.success(); 
return true;


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?

解决方案

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;

这篇关于插件无法解析为类型issue- cordova-2.7.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆