Why SQLite plugin at certain point goes in error?


#1

I have my app built in ionic 3 and I installed the plugin in this way (following the official doc):

  1. ionic cordova plugin add cordova-sqlite-storage
  2. npm install --save @ionic-native/sqlite

I don’t know why, at a certain point, suddenly, I got the following warn, and I need to re-execute the 2 command above . Why?

  • console.warn: Native: tried accessing the SQLite plugin but it’s not installed

  • console.warn: Install the SQLite plugin: 'ionic cordova plugin add cordova-sqlite-storage

Then if I re-launch the 2 commands (point 1 and 2 above), all is ok, but after various launch of my app, the problem will be present again.

Thanks help me!


#2

Where and how are you testing your app?
What is your ionic info output?
Are you interactions with the plugin wrapped in platform.ready()?


#3

ionic info outputs:

C:\project\ionic\photoShoot>ionic info

cli packages: (C:\Users\fabio\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.0.0 browser 5.0.3
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.9.1
    npm               : 5.6.0
    OS                : Windows 8.1

Environment Variables:

    ANDROID_HOME : C:\Users\fabio\AppData\Local\Android\android-sdk

Misc:

    backend : pro

In my constructor I initialize the data storage. Then I call initializeApp method that checks
this.platform.ready().then(() => …

You are saying to move the data storage init inside the check of the platform ready?


#4

Any code that interacts with native functionality (like all Ionic Native wrappers that use Cordova plugins) only works if the platform is loaded and ready. Checking for platform.ready() is one way to make sure this is the case.

Also (but probably not the cause for your problem):
Your Cordova tooling seems to be out of date, which might be causing all kinds of problems.
You can read about how to figure out the current Cordova versions and how to update CLI, platforms and plugins here: https://ionic.zone/cordova/update