After reseting plugins, Ionic 2 program doesn'

2020-07-31 01:08发布

问题:

I used many plugins in my Ionic 2 project. All things works fine before. But after launching ionic state reset --plugins, some objects cannot be found any more.

I've used Beacon Plugin in my project.

----edit----

What it doesn't work is Cannot read property 'Delegate' of undefined in var delegate = new this.locationManager.Delegate();

----edit----

The most weird thing is that ionic serve works (Browser), but ionic run android (Device) doesn't.

----edit----

After ionic platform rm android and ionic platform add android, still doesn't works.

----edit----

Doesn't work even I reinstall the Cordova.

回答1:

The command

ionic state reset --plugins

removes everything and then bring back what you have specified in the package.json file. Is the Beacon Plugin reference in your project's package.json file? If not, you will have to run

ionic plugin add https://github.com/petermetz/cordova-plugin-ibeacon.git

to add it again. Once everything is working again, you can run the following command in order to save current plugins / platforms to the package.json:

ionic state save

And then, if you need to quickly load in plugins and platforms, you can simply do:

ionic state restore

And Ionic will add in the appropriate plugins and platforms.