最白目
最白目

Reputation: 3644

phonegap barcode scanner plugin -> Reference Error

Can somebody help me with this: When I try to run the project, this is my code in the index.html`s head:

    <script type="text/javascript" src="barcodescanner.js"></script>
<script type="text/javascript" src="main.js"></script>

<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript">
    function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}


// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
    window.plugins.barcodeScanner.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);
}
);
}
</script>

I get the following error:

11-05 12:22:23.641: E/Web Console(454): ReferenceError: Can't find variable: PhoneGap at file:///android_asset/www/barcodescanner.js:57

the file is from the bar code scanner plugin. Its in the correct folder (project/assets/www). Somebody would help with this, would be great. thanks

edit:

The line wich causes the problem in the barcodescanner.js says the following:

PhoneGap.addConstructor(function() {
PhoneGap.addPlugin('barcodeScanner', new BarcodeScanner());

});

Upvotes: 0

Views: 1464

Answers (1)

Jinath Sanjitha
Jinath Sanjitha

Reputation: 108

I think the issue is that, you have not specified the correct path for your phonegap-XX.js in your maain HTML file.

Upvotes: 1

Related Questions