Search code examples
angularionic4capacitor

Capacitor/Ionic4: BarcodeScanner with plugin_not_installed


I am having trouble adding BarcodeScanner to my android build, the error was plugin_not_installed.

The app compiled without any errors, but it outputs the error on runtime. I have also tried removing/adding the android folder but still no luck.

Does anyone know what was causing this?

Install:

npm install --save @ionic-native/barcode-scanner@5.0.0-beta.21

app.module.ts:

import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx';

@NgModule({
    ...

    providers: [
        ...
        BarcodeScanner
        ...
    ]
    ...
})

home.ts:

import { BarcodeScanner, BarcodeScannerOptions } from '@ionic-native/barcode-scanner/ngx';

@Component({
  ...
})
export class HomePage implements OnInit {
  private options: BarcodeScannerOptions;

  constructor(private barcodeScanner: BarcodeScanner) {}

  scan() {
    this.options = {
      prompt: "Scan your qrcode "
    }
    this.barcodeScanner.scan(this.options).then((barcodeData) => {
      ...
    }, err => {
      console.log("Error occured : " + err);
    });
  }//func scan

}//class HomePage

======

Dependencies:

k


Solution

  • You just installed the ionic native wrapper for the plugin, but not the plugin

    For Cordova

    ionic cordova plugin add phonegap-plugin-barcodescanner

    For Capacitor

    npm install phonegap-plugin-barcodescanner