Cordova PhoneGap从2.2.0升级到5.1.1

时间:2015-07-30 09:54:15

标签: javascript java android cordova phonegap-plugins

我有Cordova应用程序,版本为2.2.0。现在我要升级,我已经做了升级部分,升级后,应用程序图像不显示,它出现了空白屏幕。即使是闪屏也没来。这是我的代码

现在我达到了一定程度。我模拟的应用程序是关于SQLitePlugin问题。当Open数据库说db.cordova没有定义

如何安装数据库 - 将数据库从db文件夹复制到android安装位置。这很好。

这是我的数据库:

    var DB              = new Object();
DB.isDBSupported    = false;
DB.isDBCreated      = false;
DB.vocabDB          = null;
DB.tables           = ['userResponses', 'wordGroups', 'words', 'wordMapping', 'checkExists', 'patch_version']
DB.createdTables    = 0;
DB.setupCallback    = null;
DB.curQP            = null;
DB.accountStatus    = false;
DB.sfx              = true;
DB.showWarnings     = true;
DB.firstLaunch      = false;

DB.initDB = function(callback) {
    this.setupCallback = callback || function(){/*console.log("null function called")*/};
    this.openDB();
    var db = this;
    if(!isPhoneGap()) {
        _.delay(this.checkDB.bind(this), 500);
    }
}

DB.checkDB = function() {
    var db = this;
    this.vocabDB.transaction(
        function (t) {
            t.executeSql('DROP TABLE checkExists', [], db.setupDBResultHandler.bind(db), db.setupDBErrorHandler.bind(db, ">>delete exists"))
        }
    )
}

DB.openDB = function() {

    try {
        if (!window.openDatabase) {
            alert('Cannot open database!');
        } else {
            var shortName = 'sns2';
            var version = '1.0';
            var displayName = 'sns2';
            var maxSize = (isAndroid()) ? 5242880 : 1000000;

            if(!isPhoneGap()) {
                this.vocabDB = window.openDatabase(shortName, version, displayName, maxSize, this.DBCreated);
            } else if(isAndroid()) {
                utils.log("ANDROID DATABASE .. ");
                this.vocabDB = window.sqlitePlugin.openDatabase(shortName, version, displayName, maxSize, this.DBCreated);
            } else if(isIOS()) {
                utils.log("iOS DATABASE .. ");
                this.vocabDB = window.sqlitePlugin.openDatabase(shortName, version, displayName, maxSize, this.DBCreated);
            }
            this.DBSupported = true;
            if(isPhoneGap()) {
                this.setupCallback();
            }

        }
    } catch(e) {
        alert("Unable to open db." + e.message);
        return;
    }
}

Service.js

function getGroupCategory(handler) {
    console.log("selecting wordGroups");
    DB.vocabDB
    .transaction(function(t) {
                 t
                 .executeSql('SELECT * FROM categories', [], function(transaction, resultSet) {
                             handler(transaction, resultSet);
                             }, DB.transactionErrorHandler
                             .bind(DB, "Error while selecting wordGroups"));
                 })
}

当我调用此方法时,我收到此错误消息could not prepare statement(1 no such table) error code 5 table is avaibale

请提出任何建议或想法..

1 个答案:

答案 0 :(得分:3)

我建议用5.1.1开始清理。通过这种方式,您可以防止升级整个过程中可能导致的问题,并且可以帮助您搜索问题的根源。

这可能听起来更像是工作,但它确实不会像升级那样麻烦,至少这是我个人经验教给我的PhoneGap。