Ionic2 RC4,在生产模式下找不到插件

问题描述 投票:1回答:1

我正在运行Ionic 2 RC4,当我运行ionic run android时,该应用程序可以运行,但是设备准备就绪会在15-18秒后触发。 我试图在设备ionic运行android --prod上运行,但它在chrome inspector中显示未安装sqlite插件,这是不正确的。 如果我转到另一个页面并返回,它将显示来自SQLite的数据。

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

}
android sqlite ionic2
1个回答
2
投票

如果有人遇到相同的问题,请回答我自己的问题。

我必须在app.component.ts中的DeviceReady中调用rootPage。 我希望它对某人有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.