由apprate插件cordova引起的eclipse编译错误

时间:2015-03-13 05:57:36

标签: android eclipse cordova ionic-framework

我正在尝试将以下2个插件安装到我的cordova应用程序中。我能够安装和编译项目,但是当我在eclipse中导入时,我发现以下错误。

Description Resource    Path    Location    Type
The declared package "org.pushandplay.cordova.apprate" does not match the expected package "org.apache.cordova.apprate" AppRate.java    /myApp/src/org/apache/cordova/apprate   line 1  Java Problem

附上屏幕截图:

enter image description here enter image description here

修改

package org.pushandplay.cordova.apprate;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageManager;
import android.content.pm.ApplicationInfo;

public class AppRate extends CordovaPlugin {
    @Override
    public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException
    {
        try {
            PackageManager packageManager = this.cordova.getActivity().getPackageManager();

            if (action.equals("getAppVersion")){
                callbackContext.success(packageManager.getPackageInfo(this.cordova.getActivity().getPackageName(), 0).versionName);
                return true;
            }
            if (action.equals("getAppTitle")) {
                ApplicationInfo applicationInfo = packageManager.getApplicationInfo(this.cordova.getActivity().getApplicationContext().getApplicationInfo().packageName, 0);
                final String applicationName = (String) (applicationInfo != null ? packageManager.getApplicationLabel(applicationInfo) : "Unknown");

                callbackContext.success(applicationName);

                return true;
            }
            return false;
        } catch (NameNotFoundException e) {
            callbackContext.success("N/A");
            return true;
        }
    }
}

感谢您的时间。

此致 Utpal

0 个答案:

没有答案