繁体   English   中英

Phonegap:对象xx在文件中没有方法'exec':///android_asset/www/cordova.js

[英]Phonegap: Object xx has no method 'exec' at file:///android_asset/www/cordova.js

我在Android中开发了一个小模块。 在Eclipse中使用调试或运行方法在我的“真实”设备上测试应用程序时,一切都可以正常运行。 使用Eclipse(Kepler),PhoneGap 3.1和Android API 10但是当我签名,导出,安装和运行应用程序时,一旦调用插件,我在调试器中看到以下错误:

file:///android_asset/www/cordova.js:第863行:未捕获TypeError:对象org.apache.cordova.al@41ae5438没有方法'exec'

未捕获的TypeError:对象org.apache.cordova.al@41ae2400在文件中没有方法'exec':///android_asset/www/cordova.js

我正在等待带有延迟对象的deviceready:

var def_deviceready = $.Deferred();
document.addEventListener("deviceready", deviceready, false);

function deviceready(){
    def_deviceready.resolve();
}
function dbaccess(query, arg, callback) {
    var dbaccess = cordova.require("cordova/plugin/dbaccess");
    $.when(def_deviceready).done(dbaccess.getData(query, arg, callback));
};

dbaccess.js:

cordova.define("cordova/plugin/dbaccess", function (require, exports, module) {
    var exec = require("cordova/exec");
    module.exports = {
            getData: function (query, arg, callback) {
                exec(callback, function(){ callback('callbackerror')}, "DBAccess", query, arg);
            }
    };
});

DBAccess.java:

public class DBAccess extends CordovaPlugin {

    HashMap<String, SQLiteDatabase> dbmap;

    /**
     * Constructor.
     */
    public DBAccess() {
        dbmap = new HashMap<String, SQLiteDatabase>();
    }
    @Override
    public boolean execute(String action, String arg, CallbackContext callbackContext) throws JSONException {
        Log.v("info", "This is what we got here: action=\'" + action +"\', arg=\'"+ arg +"\'.");
        if (action != null) {
            String Result = getData(action, arg);
            this.echo(Result, callbackContext);
            return true;
        }
        return false;
    }
.....
.....

...而且config.xml包含:

<feature name="DBAccess">
  <param name="android-package" value="com.phonegap.plugin.dbAccess.DBAccess"/>
</feature>

任何帮助是极大的赞赏...

您的脚本无法包含dbaccess.js尝试在head标记中强制添加它。 这就是为什么它不能执行该方法

我再次检查整个项目,感谢Vicky的评论(我有dbaccess.js包括......)。

我发现由于某种原因,AppLaud将我的应用程序配置为使用PhoneGap 3.0运行,但是它使用2.9 不同的config.xml导出 - 因此我的模块的包含根本不存在。 我无法弄清楚不同版本/ xml文件的配置/位置。

所以我最终创建了一个全新的项目,将我的相关文件复制到相应的文件夹中,现在我正在运行!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM