Jack He
Jack He

Reputation: 1693

Phonegap BarcodeScanner plugin could work in Android project

I have tried to integrate the BarcodeScanner plugin to one of my Phonegap project of Android. I have even done all the thing step by step as the tutorial provided by github.

The library has been imported,BarcodeScanner.java file has been imported, enter image description here

barcode.js has been imported, enter image description here

activity has been added to AndroidManifest.xml

the config.xml in res path has been also modified. enter image description here

When I test my app with eclipse, I have gotten the error below. enter image description here

By the way, I have used phonegap 2.9 and my code for using the plugin is as below.

document.addEventListener("deviceready", deviceReady, true);

    function deviceReady() {
        var scanner = window.plugins.barcodeScanner;//note that cordova.plugins.barcodeScanner has also been tried. Same error.
        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);
            });
    }

Really do not know what to do. Could you please give me any suggestion?

Thanks in advance.

Upvotes: 0

Views: 521

Answers (1)

Jack He
Jack He

Reputation: 1693

Finally, I work out it. It is because of Phonegap's version. The version should be above 3.0.

Upvotes: 1

Related Questions