Failed imports in ionic plugin

26 Views Asked by At

I am developing an ionic plugin, using Cordova, for an ionic app. By the moment, the plugin only logs an input string:

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaWebView;

public class MyCordovaPlugin extends CordovaPlugin{



private static String TAG = "MyCordovaPlugin";

public void initialize(CordovaInterface cordova, CordovaWebView webView){
    super.initialize(cordova, webView);

    Log.i(TAG, "Inicializando plugin");
}

public boolean execute (String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
    if(action.equals("echo")){
        String phrase = args.getString(0);
        Log.i(TAG, phrase);
    }
    return true;
}

}

After importing the plugin in the ionic app, I have multiple errors in the Java class...all of them because "The import org.apache cannot be resolved".

My plugin.xml:

    <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
    xmlns:rim="http://www.blackberry.com/ns/widgets"
    xmlns:android="http://schemas.android.com/apk/res/android"
    id="cordova-plugin-helloworld"
    version="0.0.1">
    <name>Hello-World</name>
    <description>Hello world!</description>
    <license>Apache 2.0</license>
    <keywords>cordova,device</keywords>
    <issue>https://issues.apache.org/jira/browse/CB/component/12320648</issue>

<engines>
    <engine name="cordova-electron" version=">=3.0.0" />
</engines>

<js-module src="www/plugin.js" name="plugin">
    <clobbers target="MyCordovaPlugin" />
</js-module>

<!-- android -->
<platform name="android">
    <config-file target="res/xml/config.xml" parent="/*">
        <feature name="MyCordovaPlugin" >
            <param name="android-package" value="MyCordovaPlugin"/>
            <param name="onload" value="true"/>
        </feature>
    </config-file>

    <source-file src="src/android/MyCordovaPlugin.java" target-dir="src" />
    <framework src="com.google.android.gms:play-services-location:$GOOGLE_PLAY_SERVICES_VERSION" />
    <framework src="com.android.support:support-v4:$ANDROID_SUPPORT_LIBRARY_VERSION" />
    <framework src="com.android.support:appcompat-v7:$ANDROID_SUPPORT_LIBRARY_VERSION" />
</platform>

<!-- ios -->
<platform name="ios">
    <config-file target="config.xml" parent="/*">
        <feature name="Device">
            <param name="ios-package" value="CDVDevice"/>
        </feature>
    </config-file>

    <header-file src="src/ios/CDVDevice.h" />
    <source-file src="src/ios/CDVDevice.m" />
</platform>

<!-- electron -->
<platform name="electron">
    <framework src="src/electron" />
</platform>

<!-- windows -->
<platform name="windows">
    <js-module src="src/windows/DeviceProxy.js" name="DeviceProxy">
        <runs />
    </js-module>
</platform>

<!-- browser -->
<platform name="browser">
    <config-file target="config.xml" parent="/*">
        <feature name="Device">
            <param name="browser-package" value="Device" />
        </feature>
    </config-file>

    <js-module src="src/browser/DeviceProxy.js" name="DeviceProxy">
        <runs />
    </js-module>
</platform>

<!-- osx -->
<platform name="osx">
    <config-file target="config.xml" parent="/*">
        <feature name="Device">
            <param name="ios-package" value="Device"/>
        </feature>
    </config-file>

    <header-file src="src/osx/CDVDevice.h" />
    <source-file src="src/osx/CDVDevice.m" />
</platform>
0

There are 0 best solutions below