ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 304 forks source link

Livereload not reloading native/plugin (SQLite) #1238

Open ssj4maiko opened 7 years ago

ssj4maiko commented 7 years ago

Short description of the problem:

Once I use the run command while testing my App, it runs fine, debug also shows it seems to be working. Once I change the code and it reloads and I get the following error on Chrome Debug. plugin_not_installed

What behavior are you expecting?

For it to keep the plugin loaded or working.

Steps to reproduce:

  1. ionic cordova run android --livereload // it works
  2. save a file to trigger a reload // it doesn't work anymore
  3. You can terminate the process and run steps 1 and 2 again
insert any relevant code between the above and below backticks
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
class DB {
    private db: any = SQLiteObject;
    constructor(){
        var sqlite = new SQLite();
        sqlite.create({
            name: 'name.db',
            location: 'default'
        })
        .then((DBO: SQLiteObject) => {
            this.db = DBO;
        })
        .catch(e => console.log(e));    //The plugin_not_installed error comes from here
    }
}
export default new DB();

Which @ionic/app-scripts version are you using?

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

    @ionic/cli-utils  : 1.12.0
    ionic (Ionic CLI) : 3.12.0

global packages:

    cordova (Cordova CLI) : 7.0.1

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.6.1

System:

    Node : v6.11.3
    npm  : 5.4.2
    OS   : Windows 10

Misc:

    backend : pro

While it's not showing, SQLlite plugin is also installed and working, since it works the first time.

condorman commented 7 years ago

i have same problem :(

condorman commented 7 years ago

i'm so sorry, work fine after platform ready event!

frohlich commented 7 years ago

Look inside your services(@Injectable), they are singleton and start with the application;

Kahel3352 commented 6 years ago

I have the same problem, did someone find a solution?

frohlich commented 6 years ago

@Kahel3352 The problem happens because Ionic has not yet loaded the SQLite plugin. To control the flow of the application use the "platform.ready ()"

Depaolifranco commented 6 years ago

Sorry, I don't understand. What should I do with platform.ready()?