Well it's pretty simple, the Plugin class which has been deprecated for awhile has been removed from the package and should be replaced with CordovaPlugin.
I'm going to go through the steps needed to upgrade your old style plugins to the new style. For this example I'm going to use the
Google Analytics plugin.
The first thing you will notice in 2.7.0+ is that the GoogleAnalyticsTracker class now has 4 errors in Eclipse. To get rid of them you would change:
import org.apache.cordova.api.Plugin;
into:
import org.apache.cordova.api.CordovaPlugin;
and:
public class GoogleAnalyticsTracker extends Plugin {
to:
public class GoogleAnalyticsTracker extends CordovaPlugin {
and now you'll notice you only have one error left in the file and that has to do with the execute method. You'll need to change the method signature from:
public PluginResult execute(String action, JSONArray data, String callbackId) {
to:
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) {
then you need to add a new import line at the top of the Java file:
import org.apache.cordova.api.CallbackContext;
and we still have one error which is now the line in which we are returning the PluginResult. That's because the method now expect a boolean to be the return value. To fix this issue you would replace:
return result;
with:
callbackContext.sendPluginResult(result);
return true;
Finally our Java code is free of error messages. Whew, were done but what's with the change to the execute method? Well let's just say there have been improvements in the way the Plugins are handled internally. What you need to know is that when you want to send a result back to the JavaScript side you now have a choice of three methods:
1) callbackContext.sendPluginResult(...)
Use this if you have constructed your own PluginResult and you want to send it to the JavaScript side.
2) callbackContext.error(int | String | JSONObject)
Skip creating a PluginResult and just invoke the error callback on the JavaScript side sending back an int, a String or a JSONObject as the method payload.
3) callbackContext.success(empty | int | String | JSONObject | JSONArray)
Again, just skip creating the PluginResult and invoke the success callback on the JavaScript side sending back an int, a String, JSONObject or JSONArray as the method payload. If you don't provide any payload the method on the JS side will be executed with no payload.
So that should get you unstuck if you have a Plugin that no longer works for you as of PhoneGap 2.7.0. You should also check out my posts on the
GalleryPlugin as shows how to write a Plugin using the new API for JS and Java.
IMPORTANT UPDATE!!!
We've heard your screams of pain and we are putting the Plugin class back for PhoneGap 2.8.1. Go read
Joe Bowser's post. The class is back in 2.8.1 and will be in 2.9.0 then gone for good in the 3.0.0 stream!