1

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

文件:///android_asset/www/cordova.js:第 863 行:未捕获的类型错误:对象 org.apache.cordova.al@41ae5438 没有方法“执行”

未捕获的类型错误:对象 org.apache.cordova.al@41ae2400 在 file:///android_asset/www/cordova.js 处没有方法“exec”

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

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>

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

4

2 回答 2

3

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

于 2013-10-20T08:32:19.430 回答
1

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

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

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

于 2013-10-21T05:54:09.507 回答