2015-07-30 7 views
26

Ho un'applicazione Cordova che è la versione 2.2.0. Ora voglio aggiornare, ho fatto parte di aggiornamento, dopo l'aggiornamento, le immagini delle applicazioni non vengono visualizzate, è venuto schermo vuoto. anche lo splash screen non è arrivato. Ecco il mio codiceAggiornamento di Cordova PhoneGap a 5.1.1 da 2.2.0

Ora ho raggiunto un certo livello. Quello che ho simulato l'applicazione, riguarda il problema SQLitePlugin. Quando Open database dice che db.cordova non è definito

Come installazione del database - copia il database dalla cartella db nel percorso di installazione di Android. Questo ha funzionato bene.

Questo è il mio database:

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")); 
       }) 
} 

Quando ho chiamato questo metodo ho ottenuto questo messaggio di errore could not prepare statement(1 no such table) error code 5 tavolo è avaibale

Si prega di qualsiasi suggerimento o idea.

+2

Sei a conoscenza di tutte le modifiche che devi eseguire per aggiornare correttamente da 2.2.0 a 5.1.1? Eccone alcuni: http://docs.phonegap.com/en/3.4.0/guide_platforms_android_upgrading.md.html Hai aggiornato/aggiornato il progetto e il PhoneGap? – Piwwoli

+1

Qualcuno ha avuto lo stesso errore su iOS: https://issues.apache.org/jira/browse/CB-1546 gli è stato suggerito quanto segue: 'Dovresti cambiare la tua chiamata a db.transaction() da: db.transaction (function, [], win, fail) a: db.transaction (function, fail, win) ' – Piwwoli

+0

Ho ricevuto questo errore' "Unchaught TypeError: Impossibile eseguire 'transaction' su 'Database': The callback fornito come parametro 2 non è una funzione. ", fonte: file: /// android_asset/www/com/jsonParser.js' – Piraba

risposta

3

Vorrei suggerire di iniziare a pulire con 5.1.1. In questo modo puoi prevenire problemi che potrebbero facilmente essere causati dall'aggiornamento dell'intera struttura e ti manterranno alla ricerca della radice dei problemi.

Questo potrebbe sembrare un lavoro in più, ma è piuttosto certo che sarà meno complicato dell'aggiornamento, almeno questo è ciò che la mia esperienza personale mi ha insegnato con PhoneGap.

Problemi correlati