sampart / cordova-plugin-app-version

Cordova plugin to return the version number of the current app [not maintained]
MIT License
401 stars 195 forks source link

Error: No provider for AppVersion in ionic 3.1.0 #91

Closed gigocabrera closed 7 years ago

gigocabrera commented 7 years ago

I'm getting the error below when I navigate to a page after adding the AppVersion logic to it.

What am I missing?

I ran this statement npm install --save @ionic-native/app-version

And then added the following logic to the settings.ts page

import { AppVersion } from '@ionic-native/app-version';

constructor(
    public nav: NavController,
    public translate: TranslateService,
    public appVersion: AppVersion,
    public auth: AuthService) {

      appVersion.getVersionNumber().then(ver => {
        this.appversion = ver;
      }).catch(function(error) {
        console.log(error);
      });
  }

main.js [sm]:1 ERROR Error: Uncaught (in promise): Error: No provider for AppVersion! Error at d (polyfills.js:3) at injectionError (main.js [sm]:1) at noProviderError (main.js [sm]:1) at ReflectiveInjector_.throwOrNull (main.js [sm]:1) at ReflectiveInjector.getByKeyDefault (main.js [sm]:1) at ReflectiveInjector.getByKey (main.js [sm]:1) at ReflectiveInjector.get (main.js [sm]:1) at AppModuleInjector.NgModuleInjector.get (main.js [sm]:1) at resolveDep (main.js [sm]:1) at createClass (main.js [sm]:1) at createDirectiveInstance (main.js [sm]:1) at createViewNodes (main.js [sm]:1) at createRootView (main.js [sm]:1) at callWithDebugContext (main.js [sm]:1) at Object.debugCreateRootView [as createRootView] (main.js [sm]:1) at d (polyfills.js:3) at injectionError (main.js [sm]:1) at noProviderError (main.js [sm]:1) at ReflectiveInjector_.throwOrNull (main.js [sm]:1) at ReflectiveInjector.getByKeyDefault (main.js [sm]:1) at ReflectiveInjector.getByKey (main.js [sm]:1) at ReflectiveInjector.get (main.js [sm]:1) at AppModuleInjector.NgModuleInjector.get (main.js [sm]:1) at resolveDep (main.js [sm]:1) at createClass (main.js [sm]:1) at createDirectiveInstance (main.js [sm]:1) at createViewNodes (main.js [sm]:1) at createRootView (main.js [sm]:1) at callWithDebugContext (main.js [sm]:1) at Object.debugCreateRootView [as createRootView] (main.js [sm]:1) at d (polyfills.js:3) at l (polyfills.js:3) at Object.reject (polyfills.js:3) at Tab.NavControllerBase._fireError (main.js [sm]:1) at Tab.NavControllerBase._failed (main.js [sm]:1) at main.js [sm]:1 at t.invoke (polyfills.js:3) at Object.onInvoke (main.js [sm]:1) at t.invoke (polyfills.js:3) at n.run (polyfills.js:3) at polyfills.js:3 at t.invokeTask (polyfills.js:3) at Object.onInvokeTask (main.js [sm]:1) at t.invokeTask (polyfills.js:3) at n.runTask (polyfills.js:3)

nikmartin commented 7 years ago

@gigocabrera why did you close this, do you resolve it? I'm getting the same error.

gigocabrera commented 7 years ago

@nikmartin I followed the official ionic instructions http://ionicframework.com/docs/native/app-version/ And then I added the provider to the app.module.ts in my app https://github.com/gigocabrera/CajaFuerte-app/blob/master/src/app/app.module.ts#L134 That fixed it. Hope that helps you too!

nikmartin commented 7 years ago

It did indeed help! I always forget to add plugins to app.module.ts!

ArosPrince commented 5 years ago

I have the same problem. And yes, I did add it to app.module.ts.

Any ideas?

tr1ms commented 5 years ago

I worked for me, I add it to the app.module and everything is working as expected. Thanks