package uk.co.whiteoctober.cordova;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageManager;

public class AppVersion extends CordovaPlugin {
	@Override
        public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

		try {	
			if (action.equals("getVersionNumber")) {
				PackageManager packageManager = this.cordova.getActivity().getPackageManager();
				callbackContext.success(PluginResult.Status.OK, packageManager.getPackageInfo(this.cordova.getActivity().getPackageName(), 0).versionName);
			return true;
			}
			return false;
		} catch (NameNotFoundException e) {
			callbackContext.success('Error');
			return true;
		}
	}

}

package uk.co.whiteoctober.cordova;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageManager;

public class AppVersion extends CordovaPlugin {
	@Override
        public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

		try {	
			if (action.equals("getVersionNumber")) {
				PackageManager packageManager = this.cordova.getActivity().getPackageManager();
				callbackContext.success(packageManager.getPackageInfo(this.cordova.getActivity().getPackageName(), 0).versionName);
			return true;
			}
			return false;
		} catch (NameNotFoundException e) {
			callbackContext.success("N/A");
			return true;
		}
	}

}

Update AppVersion.java