Monday, September 24, 2012

Apache Cordova (Phonegap) and the BarcodeScanner Plugin for Android

This documentation relates to following versions:
Cordova 2.0.0

For one of my projects I have to use the BarcodeScanner Plugin for Android. I had some problems getting it to work so I describe what had to be done in detail.

Create a new Android Project
First I created a new Android Project called Testbarcode according to the following documentation:

Import the LibProject
Then I imported the LibProject as seperate project and turned it in to a Library Project in the Eclipse application properties.

Use the LibProject in the Testbarcode Project
I added the LibProject in to my Testbarcode project according to the description but there are some differences.

The difference is that in newer versions the file in res/xml is not called plugins.xml anymore but config.xml. So the following line:

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

has to be added to config.xml and not plugins.xml. I received a class not found error.

Simon Mac Donald has described this on his blog:

Using the index.html from Simon Mac Donald for testing
I have used the example index.html from Simon Mac Donalds Blog and changed the js from phonegap-1.2.0.js to cordova-2.0.0.js.

That was it. I could scan barcodes.


  1. This is a wonderful blog and I guess it will be helpful in getting understanding of barcode scanner plug in for android for many people.
    epos x