Domanda

i get an error, when i try to start the scanner.

<script type="text/javascript" src="js/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.4.2.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="barcodescanner.js"></script>
<script type="text/javascript" src="childbrowser.js"></script>
<script type="text/javascript" src="js/index.js"></script>

Here is the error.

enter image description here

This is my javascript code. I take the exsample code of the barcode scanner from phonegap.

scan : function() {
        console.log('scanning');
        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);

            console.log(result);
        }, function(error) {
            console.log("Scanning failed: ", error);
        });

I dont found a way to fix this problem

EDIT Could some upload or copy paste the config.xml file please?

È stato utile?

Soluzione 2

OKay, this works great for me.

<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns   = "http://www.w3.org/ns/widgets"
xmlns:gap   = "http://phonegap.com/ns/1.0"
id          = "com.phonegap.example"
versionCode = "10" 
version     = "1.0.0" >

<!-- versionCode is optional and Android only -->

<name>PhoneGap Example</name>

<description>
  An example for phonegap build docs. 
</description>

<author href="https://build.phonegap.com" email="support@phonegap.com">
  Hardeep Shoker 
</author>

<!-- We'll include the Barcode plugin as an example -->
<gap:plugin name="com.phonegap.plugins.barcodescanner" />

Altri suggerimenti

check your config.xml. make sure you add this phonegap plugin barcode scanner.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top