user487779
user487779

Reputation: 630

fileName.java:1 error ';' expected - Visual Studio Cordova Build with Android plugin

I have used the plugman command from the tutorial

. It has created the necessary files for a test plugin which I have not amended. I have added the plugin to my cordova visual studio project using the Plugins tab of config.xml to this local plugin. When I build I get the error

Severity Code Description Project File Line Suppression State Error C:\Users\tonyh\OneDrive\Documents\Visual Studio 2015\Projects\AmILateTestDelete\AmILateTestDelete\platforms\android\src\cordova-plugin-am-i-late\AmILate\AmILate.java:1: error: ';' expected AmILateTestDelete 1

package cordova-plugin-am-i-late;

import org.apache.cordova.CordovaPlugin;

import org.apache.cordova.CallbackContext;

import org.json.JSONArray; import org.json.JSONException;

import org.json.JSONObject;

/** * This class echoes a string called from JavaScript. */

public class AmILate extends CordovaPlugin {

@Override

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

        if (action.equals("coolMethod")) {

        String message = args.getString(0);

        this.coolMethod(message, callbackContext);

        return true;

    }

        return false;

    }


private void coolMethod(String message, CallbackContext callbackContext) {

        if (message != null && message.length() > 0) {

                callbackContext.success(message);

    } else {

                callbackContext.error("Expected one non-empty string argument.");

    }

    }

}

Has anyone encountered this problem ?

Many thanks.

Tony

Upvotes: 2

Views: 738

Answers (1)

Jordan Matthiesen
Jordan Matthiesen

Reputation: 1480

Your package name contains hyphens (-), which aren't valid characters in an identifier name (they can be confused with a subtraction/- operation). Try removing those and your file should compile.

Upvotes: 2

Related Questions