Ionic 4 - Native: tried accessing the SQLite plugin but it's not installed

I could finally solve the problem.

After uninstalling and installing the plugin and android platform in different version etc… which didn’t help.

I figured out that the device ready in app.component.ts is apparently not enough to make sure that the device is “really” ready. since I use the database as a service I had to put the device ready stuff in my service constructor and now it works.

this is my constructor in the databse service:

constructor(
        private sqlite: SQLite,
        private platform: Platform
    ) {
        this.platform.ready().then(() => {
            this.createDatabaseObject();
        });
    }

createDatabaseObject(): void {
        this.sqlite.create({
            name: this.databaseName,
            location: this.databaseLocation
        }).then((db : SQLiteObject) => {
            this.dbHandler = db;
            this.createTables();
        });
    }
2 Likes