Search code examples
androidcordovanetbeansbarcode-scanner

phonegap,cordova; barcodescanner plugin gives 'Scannig failed:Class not found' error


I am using phonegap 3.4.0 with netbeans. I add barcodeScanner pluging to my project, when i run this code :

var scanner = cordova.require("cordova/plugin/BarcodeScanner");
                scanner.scan(function(result) {
                            alert("We got a barcode\n" +
                                    "Result: " + result.text + "\n" +
                                    "Format: " + result.format + "\n" +
                                    "Cancelled: " + result.cancelled);
                             }, function(error) {
                              alert("Scanning failed: " + error);
                  });

gives the Scannig failed:Class not found error.

I try to solve the error with adding this lines

<plugin name="BarcodeScanner"value="com.phonegap.plugins.barcodescanner.BarcodeScanner"/>

to my res/xml/config.xml file. But after adding this lines and built netbeans project the changes that i made in config.xml being revoked by netbeans


Solution

  • I solve the problem by adding a line for barcodeScanner plugin to PROJECT_PATH/nbproject/plugins.properties file as follow

    com.phonegap.plugins.barcodescanner.BarcodeScanner=https://github.com/wildabeast/BarcodeScanner.git

    after that when i build the project netbeans automatically updated my config.xml and barcode scanner worked fine.