Ionic native issue in ionic app

You are welcome dude…glad it worked

save my day thanks :slight_smile:

2 Likes

Enjoy the rest of the day man

Update on this. The Ionic Team seem to have sorted it all out with Ionic 4.

$ ionic info

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (C:\Users\thebi\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.3.1
   @angular-devkit/build-angular : 0.13.8
   @angular-devkit/schematics    : 7.3.8
   @angular/cli                  : 7.3.8
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 6 other plugins)

System:

   Android SDK Tools : 26.1.1 (C:\Users\thebi\AppData\Local\Android\sdk)
   NodeJS            : v10.15.3 (C:\Program Files\nodejs\node.exe)
   npm               : 6.9.0
   OS                : Windows 10

If you follow the docs and install the plugins and ionic native extensions as documented, it will work.

$ ionic cordova plugin add phonegap-plugin-barcodescanner
$ npm install @ionic-native/barcode-scanner

Except if like me, you were migrating a project from V3, and you left one of your imports minus the /ngx. I came across this forum after attempting to add the native barcode scanner. After doing so, I got the errors described here. It turned out that the error that was stuffing me up was that the SplashScreen was not imported correctly into the module. It was missing the /ngx. Now why this didn’t cause the app to fail in the first place, I have no idea, but after updating all my native imports, it works. I’m writing this because who in their right mind wants to jump through a bunch of hoops working with @4 versions of various modules if they don’t have to.

For those that end here running on Ionic 5 just fix your import statement from:

import { BarcodeScanner } from ‘@ionic-native/barcode-scanner’;

to:

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

1 Like