Problems with the Barcode Scanner plugin


Hey Ionic community,
I’m trying to get the Barcode Scanner plugin to work in a small app.
I installed it by executing this commands:

npm install ionic-native --save
ionic plugin add phonegap-plugin-barcodescanner

My code for the page I want to trigger the Barcode Scanner from looks like this:



My problem is that when I start the app on my Nexus 5 via ionic run and click my test button I get a generic error message saying that there has been a problem with the Android camera and that it could help to reboot the device.
A screenshot of the message (sorry for it being in German):

I tried restarting my device and the strange thing is that the camera of my device works normally in the camera app.

What can I do to fix my problem (I hope this isn’t a stupid question :innocent:)?
Thanks in advance for the help.


It seems to be related to the following post:


What version of android do you use? Latest android version need to asign permissons to the app.

I had the same problems with android 6.0.1. When you allow your app to make use of the camera the problem should be gone and u can start scanning barcodes!


Thank you, you’re right. I guess I’ll wait for some kind of fix like the starter of the other thread does.


Also check out the section Checking permission in the Barcode Scanner plugin docs.


I use Android 6.0.1. Thanks for the hint, this solves the problem for now but of course a default checked permission would be better. :slight_smile:


Thanks for the hint.
I tried to request the permission in two ways which both failed:
Version 1:
I added BarcodeScanner.requestCameraPermission(); to my test function. This caused the error Error TS2339: Property 'requestCameraPermission' does not exist on type 'typeof BarcodeScanner'..
Version 2:
I added cordova.plugins.barcodeScanner.requestCameraPermission(); to my test function. This resulted in the error Error TS2304: Cannot find name 'cordova'. 7.5 MB bytes written (12.23 seconds).

Am I doing something wrong?


Looks like you are missing some typing files. At least for the second error. Do you have typings installed? npm install -g typings try to install cordova typings install cordova --save --ambient


Note that backward compatibility was added by checking for permission in the scan function. If permission is needed the scan method will now show the permission request popup. The user will then need to allow camera access and launch the scanner again.

So you don’t need to call these methods.

PS: fix(English)


Thanks for the suggestion. I executed the commands you suggested but that only changed my second error message to Error TS2339: Property 'barcodeScanner' does not exist on type 'CordovaPlugins'..


Right, that’s strange, I wasn’t shown the permissions popup when I tried to start my scanner (not the first time and never after that).


Try update barcode plugin

PS last version is 4.1.0


ionic plugin update gave me this:

WARN: ionic.config.js has been deprecated, you can remove it.
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-splashscreen 3.2.1 "Splashscreen"
cordova-plugin-statusbar 2.1.2 "StatusBar"
cordova-plugin-whitelist 1.2.1 "Whitelist"
cordova-sqlite-storage 1.2.1 "Cordova sqlite storage plugin (core version)"
ionic-plugin-keyboard 2.0.1 "Keyboard"
phonegap-plugin-barcodescanner 4.1.0 "BarcodeScanner"

I suppose everything is set up as it should be, right?


@lx4r There’s a workaround you could try - target a lower SDK version:

Camera plugin and barcode scanner plugin stopped working in beta.6 (update: it's a permissions issue for marshmallow devices)

Thanks a lot, this fixed my issue for now. Hopefully there will be a real fix soon. :thumbsup:


After lower the SDK version to 22,

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />

also not working for me? Any other solution is there?