Ionic home page component: No provider for Deploy

Hi,

I’m evaluating the hot redeploy functionality. The doc refers to the Deploy dependency to inject in a module.

I created a blank project and adapted the home page:

import { Component } from '@angular/core';
import { Deploy } from 'cordova-plugin-ionic/dist/ngx';
import { environment } from 'src/environments/environment';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss']
})
export class HomePage {
  isProduction: boolean;
  versionsAvailable: number = 0;

  constructor(private _deploy: Deploy) {
    this.isProduction = environment.production;
  }

  async onCheckVersions() {
    const versions = await this._deploy.getAvailableVersions();
    this.versionsAvailable = versions.length;
  }
}

Running this in the browser fails, the same goes for a cordova run (platform: browser); The cordova run with Android as target platform (phsyical device) fails for the same reason, adding that some CORS issue happened accessing pro-manifest.json.

This makes me suppose it’s a basic Angular issue with importing the Deploy module.

ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[HomePage -> Deploy]: 
  StaticInjectorError(Platform: core)[HomePage -> Deploy]: 
    NullInjectorError: No provider for Deploy!
Error: StaticInjectorError(AppModule)[HomePage -> Deploy]: 
  StaticInjectorError(Platform: core)[HomePage -> Deploy]: 
    NullInjectorError: No provider for Deploy!

I don’t see a specifc cordova module to import and the doc doesn’t mention anything in that regard.

To validate that the config is done, I run the ionic deploy add <...> command and the system confirms:
Appflow Deploy plugin is already installed.

Thanks in advance for your attention and thoughts!

1 Like

Hi, Are you sure you imported the Provided in the app.module.ts file?

Hi,
Thanks; No I haven’t - actually I can’t find documentation regarding a Module that should be imported or a service added to the providers. I’m looking in the ./node_modules/

Opening , node_modules\cordova-plugin-ionic\src\browser\IonicCordovaCommon.js it shows that a dummy interface is made available to “crash gracefully” in case this cordova feature is attempted to be used via the Browser (cordova run platform browser).

So I’m missing something (possibly an obvious one), but can’t figure out what it is - a module to import, a service to provide…

function notSupported(win,fail) {
    console.log('IonicCordova is not supported on browser platform');
    setTimeout(function(){
        if (win) {
            win();
        }
    },0);
}

function getPreferences(win,fail) {
    setTimeout(function(){
        win({
            minBackgroundDuration: 30,
            disabled: true
        });
    },0);
}

module.exports = {
    getPreferences: getPreferences,
    getAppInfo: notSupported,
    setPreferences:notSupported,
    configure: notSupported
};

require("cordova/exec/proxy").add("IonicCordovaCommon", module.exports);

Okay, looking at that error, i just feel adding the Deploy to your provider array in app.module.ts should fix it

Nope, didn’t work either. I’ll keep looking and post updates. Thanks for your time!

Did you sloved this problem ?
I have the same problem … can’t slove it

Also having this issue, tried doing the same stuff with adding Deploy to my app.modules.ts with same results.
Did you find the answer, or can anyone else shed some light on this?

Ran into the same issue with no solution.

Adding. Deploy to the Providers; does fix the problem.