I've added the AppVersion Ionic native plugin (https://ionicframework.com/docs/native/app-version#usage). After try to provide it into my app.module.ts i've an error at compilation like "No provider exists for AppVersion" ...

I thinking that maybe from Ionic 4/recent version of AppVersion, i need to follow this instructions : https://ionicframework.com/docs/native/#Add_Plugins_to_Your_App_Module which say to provide the plugin into the app.module.ts with a import like this :

import AppVersion from '@ionic-native/AppVersion/ngx'.

The code compile. Perfect. But sadly at runtime i have an error which say:

TypeError: Object(__WEBPACK_IMPORTED_MODULE_1__ionic_native_core__["cordova"]) is not a function. (In 'Object(__WEBPACK_IMPORTED_MODULE_1__ionic_native_core__["cordova"])(this, "getPackageName", {}, arguments)', 'Object(__WEBPACK_IMPORTED_MODULE_1__ionic_native_core__["cordova"])' is an instance of Object) getPackageName — index.js:28...

So my solution to this time-consuming problem, was to take an hold version of the AppVersion, which works on another project :

package.json :

...
"@ionic-native/app-version": "^4.18.0",
...
"cordova-plugin-app-version": "0.1.9",
...

With this, i can import normally the plugin into my app.module.ts (import AppVersion from '@ionic-native/AppVersion') and everything is ok.

There is the versions of my stack :

Ionic:

ionic (Ionic CLI) : 4.1.2 (/usr/local/lib/node_modules/ionic) Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.1.11

Cordova:

cordova (Cordova CLI) : 8.1.1 ([email protected]) Cordova Platforms : android 7.1.1, ios 4.5.5 Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 8 other plugins)

System:

Android SDK Tools : 26.1.1 (/Users/maximedesogus/Library/Android/sdk/) ios-deploy : 1.9.4 NodeJS : v8.12.0 (/usr/local/bin/node) npm : 6.4.1 OS : macOS Xcode : Xcode 10.1 Build version 10B61

1

There are 1 best solutions below

1
On

Downgrade your current App version plugin, to do that remove this plugin first after that install this plugin again like::

1) ionic cordova plugin add cordova-plugin-app-version 

2) npm i @ionic-native/[email protected]