Software Archive
Read-only legacy content
17061 Discussions

Barcode Scanner not working with Cordova Building

Loredano_R_
Beginner
1,270 Views

Hi,

I created an application that needs to scan the bar codes. So i used the intel.xdk.device.scanBarcode() method to realize this function. My problem is that the build of my application doesn't work if i build it with Cordova builder. This is my code:
 

function BarcodeScanner() {
    try {
        intel.xdk.device.scanBarcode();
    }
    catch (err) {
        alert(err.message); //This throw "Cannot read property 'scanBarcode' of undefined"
    }
}

document.addEventListener("intel.xdk.device.barcode.scan", function (evt) {
    intel.xdk.notification.beep(1);
    if (evt.success == true) {
        artsel = SearchArticoloByBarcode(evt.codedata);
        DisplayInfoArt();
        ConfArtCheck();
        setTimeout(function () { $.ui.scrollToTop("page4", "200") }, 200);
    }
    else {
        alert("Errore lettura");
    }
}, false);

The build is successful, but when I run my app I catch an error that says: "Cannot read property 'scanBarcode' of undefined".
If I build the application with legacy builder the app works, but I'd like to use the other builder because the app created is faster and lighter.
The app works also with the Debugger. For now I'm working with an Android Phone (Nexus 5), but the app should run also on iOS and Windows Phone.

Does someone know something about this issue?

Thanks for the help.

0 Kudos
10 Replies
John_H_Intel2
Employee
1,270 Views

Did you include the Intel Device plugin? You need to enable that in the Plugins settings, under the Projects Tab in the XDK.

0 Kudos
Loredano_R_
Beginner
1,270 Views

Yes, I included that plugin. Futhermore the builder says that the plugin has been installed.
Log File: https://drive.google.com/open?id=0B1GcLTTsayBNTGxfTHREY2xFZjg&authuser=0
 

0 Kudos
John_H_Intel2
Employee
1,270 Views

Can you try adding a 3rd party cordova barcode scanner and see if that works? 

This one appears to be pretty popular  http://plugins.cordova.io/#/package/com.phonegap.plugins.barcodescanner

0 Kudos
Alexander_F_
Novice
1,270 Views

Hey I have this problem now, can you let me know if you find the solution.

Thank You

0 Kudos
Marco_M_1
Beginner
1,270 Views

Hi everybody, I'am sorry for the english, but italian school is not good.

However, I have a similar problem: with ios, android, com.phonegap.plugins.barcodescanner

work fine, but if I compile with legacy for Windows Phone, cordova.plugins is undefined.... and then scan failed. I think, but I'm not sure, plugin not deployed.

Any idea? Thanks a lot.

Bye bye from florence.

 

 

0 Kudos
Marco_M_1
Beginner
1,270 Views

For Loredano. Dear friend, read on google: many people says is better use com.phonegap.plugins.barcodescanner instead of xdk.device.barcode, becasue is not maintened from Intel.

Bye

0 Kudos
Loredano_R_
Beginner
1,270 Views

Hi, now I use the cordova plugin for the barcode scanner and I compile in Cordova mode for Androd. With last updates Intel has deprecated the Legacy build, so I decided to re-write the application to compile it in cordova mode. I think this way is better, the app is smoother and ligther.

Bye Bye

0 Kudos
Marco_M_1
Beginner
1,270 Views

Hi Loredano: but for windows Phone have any idea ?

0 Kudos
Marco_M_1
Beginner
1,270 Views

Hi every body!! I understand the problem. If you build with legacy (example windows phone) thirdy part plugins CANNOT INDLUDES in the project......  Then I come back to xdk.device.scanbarcode for WP8.

Bye

0 Kudos
John_H_Intel2
Employee
1,270 Views

Correct. The legacy builds do not make use of the Cordova plugins. The legacy builds will soon be removed and you will not be able to build them anymore.

0 Kudos
Reply