Note that there are some explanatory texts on larger screens.

plurals
  1. POUndefined EXEC method in PhoneGap 2.0
    primarykey
    data
    text
    <p>When trying to execute a phonegap plugin method, the application raises this error:</p> <blockquote> <p><code>TypeError 'undefined' is not a function (evaluating 'cordova.exec( ...</code></p> </blockquote> <p>Code included in app:</p> <p><strong>Javascript plugin link (file settingswrite.js)</strong></p> <pre><code>window.SettingsWrite = function(objectData, successCallback, failureCallback) { var options = {}; for (var key in objectData) { options[key] = objectData[key]; } cordova.exec( successCallback, failureCallback, 'SettingsWrite', 'set', new Array(options) ); }; </code></pre> <p><strong>Javascript code to make use of plugin (file app.js)</strong></p> <pre><code>function setActualPosition() { // appMap is an application global object var map = appMap.getMapEdgesProjection(); window.SettingsWrite([{ x: map.minh, y: map.maxh }], function(r){ alert(r); }, function(e){ alert("Operation error"); console.log('ERROR: ' + e); }); } </code></pre> <p>Plugin is declared in config.xml as:</p> <pre><code>&lt;plugin name="SettingsWrite" value="es.mycompany.cordova.plugin.SettingsWrite"/&gt; </code></pre> <p>Javascript code is executed index.html (located at assets folder and included into WebView):</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Test Mobile&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"&gt; &lt;meta name="apple-mobile-web-app-capable" content="yes"&gt; &lt;script src="assets/js/cordova-2.0.0.js"&gt;&lt;/script&gt; &lt;script src="assets/js/jquery-1.7.2.min.js"&gt;&lt;/script&gt; &lt;script src="assets/js/settingswrite.js"&gt;&lt;/script&gt; &lt;script src="assets/js/app.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="divMapContainer"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And the plugin Java class (as defined in Phonegap docs):</p> <pre><code>public class SettingsWrite extends Plugin { public static final String ACTION = "set"; @Override public PluginResult execute(String action, JSONArray data, String callbackId) { if(ACTION.equals(action)) { . . . } else { . . . } } </code></pre> <p>The plugin runs in Android 3.1 device and all needed files are correctly included to the project(cordova-2.0.0.js and cordova-2.0.0.jar). May someone help me?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload