Hey guys,
I’m working on an app which uses the SQLite plugin.
All worked fine till friday, when my app crashed and the config.xml became corrupted. I made a new project installed all the plugins again put the code back(generated pages with the cli command and rewrote the code).
It all worked fine again did have a white screen but a second startup did what it had to do.
now I’m starting up my app with ionic cordova run android
, it starts the app loads the splashscreen but then I get a white screen.
While running the debugger I get this:
App successfully launched
Attaching to android
Forwarding debug port
Attaching to app.
Native: tried accessing the SQLite plugin but it's not installed. common.js:272
Install the SQLite plugin: 'ionic cordova plugin add cordova-sqlite-storage' common.js:275
ERROR AppModule:1
Error: Failed to create db connection AppModule:1
ERROR CONTEXT AppModule:1
DebugContext_ {view: Object, nodeIndex: 1, nodeDef: Object, elDef: Object, elView: Object}
AppModule:1
Error: Failed to create db connection main.ts:12
Ionic Native: deviceready event fired after 548 ms bootstrap.js:10
SQLite is installed, and I even re-installed it but didn’t work.
When my app starts I load up my SQL in app.component.ts which calls my function initSql()
Which is in a global service:
import { SQLite, SQLiteObject } from '@ionic-native/sqlite/ngx';
private db: SQLiteObject; public initSql() {
const conn = this.sqlite.create({
name: 'berichten.db',
location: 'default'
});
if (conn == null) {throw Error('Failed to create db connection'); }
conn.then((data) => {
this.db = data;
// tslint:disable-next-line:max-line-length
this.db.executeSql('CREATE TABLE IF NOT EXISTS berichten (ID INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, `text` TEXT, date NUMERIC)', [] ).then(() => {
this.notifications = this.getNotifications();
})
.catch(error => console.error('sqlite create error', error));
}).catch(error => console.error('initsql', error));
}
What I did notice:
When I disable the initSql() in my app.component the app does start.
The AppModule:1 is not an existing file in my project base folder(it does not link to src/app)
I’ve also tested the project on my colleague’s phone with the initSql() enabled, and it works.
Tomorrow I’ll be trying it on another phone
I hope I’ve provided enough information.