Latest Cordova using permissions fails

  • After upgrading to the latest Cordova in Monaca i’m unable to use the camera/barcodescanner. Is there an example of what needs to be configured or how to request the permissions etc… ?

  • Monaca

    Here is an example of how to request the permission within config.xml file:

    <plugin name="cordova-plugin-camera">
          <variable name="CAMERA_USAGE_DESCRIPTION" value="App would like to access the camera." />
          <variable name="MICROPHONE_USAGE_DESCRIPTION" value="App would like to access the microphone." />
          <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="App would like to access the library." />

  • I’m getting an error in the Monaca Debugger
    Sorry, the Android camera encountered a problem. You may need to restart the device.

    I’ve listed the code below and I’ve added the xml from your previous comment.

            try {
                var scanner = cordova.require("cordova/plugin/BarcodeScanner");
                scanner.scan( function(result) {
                                  if (result.cancelled == false) {  
                                  } else {
                                      ons.notification.alert("Scanning failed"); 
                    }, function(error) {
                        ons.notification.alert("Scanning failed: " + error);
            } catch (err) {

  • Monaca

    BarcodeScanner Plugin (the built-in plugin on Monaca Cloud IDE) can’t be used with Android version 6 or higher and it may also not work with Cordova 6.5 projects for iOS platform. In this case, please use the external PhoneGap Plugin BarcodeScanner.

  • @khemry am I able to add an external plugin with my current account ?

  • Monaca

    @johnfacey Are you a Free/Basic plan user? If so, you can’t import the external plugin. How about trying a free 14 days trial with Developer plan?

  • Thanks I will try that

  • I tried added that external plugin but then I see that ‘barcodeScanner’ is undefined. Would this be something in my config.xml? How do I know if a plugin is configured correctly ?

  • @johnfacey, for 3rd party plugins to work, you need to create a custom debugger in the Monaca IDE (See Debug menu) or create a release version (APK) file and install on Android device.

Log in to reply