【问题标题】:Cordova PhoneGap upgrade to 5.1.1 from 2.2.0Cordova PhoneGap 从 2.2.0 升级到 5.1.1
【发布时间】:2015-10-21 14:54:03
【问题描述】:

我有 2.2.0 版的 Cordova 应用程序。现在我要升级,我已经做了升级部分,升级后,应用程序图像不显示,它来黑屏。连闪屏也没来。这是我的代码

现在我达到了某种程度。我模拟的应用程序是关于SQLitePlugin 的问题。当打开数据库说 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

请有任何建议或想法..

【问题讨论】:

  • 您是否了解从 2.2.0 正确升级到 5.1.1 所需进行的所有更改?以下是一些:docs.phonegap.com/en/3.4.0/…你升级/更新了项目以及phonegap吗?
  • 其他人在 iOS 上遇到了与您相同的错误:issues.apache.org/jira/browse/CB-1546 他被建议如下:You should change your db.transaction() call from: db.transaction(function, [], win, fail) to: db.transaction(function, fail, win)
  • 我收到了这个错误" Uncaught TypeError: Failed to execute 'transaction' on 'Database': The callback provided as parameter 2 is not a function.", source: file:///android_asset/www/com/jsonParser.js
  • 我改的是DB.vocabDB.transaction(function(t) { t .executeSql('SELECT * FROM categories', function(transaction, resultSet) { alert("getGroupCategory == " + resultSet.row.length); handler(transaction, resultSet); }, DB.transactionErrorHandler .bind(DB, "Error while selecting wordGroups")); })
  • DB.transactionErrorHandler.bind(DB, "Error while selecting wordGroups") 由于某种原因不是函数?

标签: javascript java android cordova phonegap-plugins


【解决方案1】:

我建议从 5.1.1 开始清理。这样你就可以防止升级整个东西很容易引起的问题,并让你不断寻找问题的根源。

这听起来可能需要做更多的工作,但肯定会比升级更轻松,至少这是我使用 PhoneGap 的个人经验告诉我的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-17
    • 2013-12-07
    • 2015-08-10
    • 2017-04-21
    相关资源
    最近更新 更多