2017-01-09 1 views
1

Я запускаю Ionic 2 RC4, и когда я запускаю ионный run android, приложение работает, но устройство готово стреляет через 15-18 секунд. Я попытался запустить на Android-андроиде Android -prod, но он показывает в хромовом инспекторе, что плагин sqlite не установлен, что неверно. Если я перейду на другую страницу и вернусь, она отобразит мои данные из SQLite.Ionic2 RC4, не находит плагин в рабочем режиме

constructor is called 
main.js:1 Native: tried accessing the SQLite plugin but it's not installed. 
x @ main.js:1 
main.js:1 Install the SQLite plugin: 'ionic plugin add cordova-sqlite-storage' 
x @ main.js:1 
cordova.js:1223 deviceready has not fired after 5 seconds. 
cordova.js:1216 Channel not fired: onFileSystemPathsReady 
main.js:4 Native: deviceready did not fire within 2000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them. 
(anonymous) @ main.js:4 
main.js:4 DEVICE READY FIRED AFTER 2684 ms 
error getting scheduled matches TypeError: Cannot read property 'executeSql' of undefined 
at _ (main.js:1) 
at main.js:1 
at main.js:1 
at new t (polyfills.js:3) 
at e (main.js:1) 
at s (main.js:1) 
at t.<anonymous> (main.js:1) 
at t.value [as executeSql] (main.js:1) 
at t.getScheduledMatches (main.js:9) 
at t.getMatchInfo (main.js:23) 

Я попытался разместить устройство в нескольких разных местах, и я также вошел в систему во многих местах. Последний журнал консоли, который называется, называется конструктором

constructor(public timeSince: TimeSinceService, 
    public platform: Platform) { 
    console.log("constructor is called"); //called 

    if(!this.isOpen){    
     this.db = new SQLite(); 
     this.db.openDatabase({name: "aces.db", location: "default"}).then(() => { 
      console.log("open Database"); // not called 

      this.db.executeSql('PRAGMA user_version = 0', []).then(()=>console.log("yesss")) // not called 
      this.db.executeSql('PRAGMA user_version', []).then(data => { 
       if(data.rows.item(0).user_version !== current_version){ 
       console.log("versions do not match"); 
       } 
      }) 

      this.db.executeSql('PRAGMA foreign_keys = ON', []).then(()=>{ 
       let query_matches = 'CREATE TABLE IF NOT EXISTS matches '+ 
           '(id INTEGER PRIMARY KEY AUTOINCREMENT,'+ 
           ...'; 
       let query_comments = 'CREATE TABLE IF NOT EXISTS comments '+ 
          '(id INTEGER PRIMARY KEY AUTOINCREMENT, '+ 
          ...'; 
       let query_points = 'CREATE TABLE IF NOT EXISTS undo'+ 
          '(point_id INTEGER PRIMARY KEY AUTOINCREMENT,'+ 
          ...'; 
       let query_organizations = 'CREATE TABLE IF NOT EXISTS organizations '... 
       let query_users = 'CREATE TABLE IF NOT EXISTS users '+ 
          '(id INTEGER PRIMARY KEY AUTOINCREMENT,'+ 
          ...'; 
       Promise.all([  
        this.db.executeSql(query_matches, {}).then(() => { 
         console.log("table created"); 
        }, (err) => console.error('Unable to execute sql for matches: ', err)), 
        this.db.executeSql(query_comments, {}).then(() => { 
         console.log("comment table created"); 
        }, (err) => console.error('Unable to execute sql for create comment table: ', err)), 
        this.db.executeSql(query_organizations, {}).then(() => { 
        console.log("table organizations created"); 
        }, (err) => console.error('Unable to execute sql: ', err)), 
        this.db.executeSql(query_points, {}).then(() => { 
         console.log("undo table created"); 
        }, (err) => console.error('Unable to execute sql for undo table: ', err)), 
        this.db.executeSql(query_users, {}).then(() => { 
         console.log("table users created"); 
         }, (err) => console.error('Unable to execute sql: ', err)) 
       ]).then(()=> { 
        console.log("called promise all"); 
        this.isOpen = true 
       }) 
      }) 
     }, (error) => console.log("ERROR couldn't open database from sqlite service: ", error)); 
    } 

} 

ответ

2

Отвечая на мой вопрос, если кто-то сталкивается с той же проблемой.

Мне пришлось вызвать rootPage внутри DeviceReady внутри моего app.component.ts. Надеюсь, это помогает кому-то.

+1

У меня такие же проблемы с девицериадой, которая не срабатывает. Что вы подразумеваете под «call rootPage»? – Johncl

+1

Вместо того, чтобы давать значение при объявлении переменной rootPage = TabsPage, просто объявите переменную rootPage; а затем в готовом устройстве введите значение rootPage. – ACES

+0

У меня была такая же проблема, и вы спасли мой день. Большое спасибо. –

Смежные вопросы