Barcode Android not working

  • 1
  • Problem
  • Updated 5 years ago
  • Solved
I have for iOS successfully implemented the barcode plugin into my app.
Sadly it's not working on Android. I get the following error:
"Scanning failed: Class not found"

Link to my code: www.reformationzweinull.de/app/
Link to complete .zip: www.reformationzweinull.de/app/refo.zip

Can anyone find the reason for this?
Many thanks!
Photo of Lutz Neumeier

Lutz Neumeier

  • 8 Posts
  • 1 Reply Like

Posted 6 years ago

  • 1
Photo of John Weidner

John Weidner, Champion

  • 435 Posts
  • 80 Reply Likes
Are you using PhoneGap Build? If so, I don't think you are suppose to reference the barcodescanner.js file in your index.html. The build process should handle that for you. Try removing that script line from your index.html and rebuild.
Photo of Lutz Neumeier

Lutz Neumeier

  • 8 Posts
  • 1 Reply Like
Thanks, tried that but sadly with no effect. Same error message.
Photo of John Weidner

John Weidner, Champion

  • 435 Posts
  • 80 Reply Likes
What Android device are you using for testing? Is there anything more to the error message? I had no problem using the plugin on a Samsung GS5.
Photo of Lutz Neumeier

Lutz Neumeier

  • 8 Posts
  • 1 Reply Like
Samsung S3 I'm using and PhoneGap Build.
Nothing more but this error message and scanning not working.
Is there any problem in the way I have implemented the Plugin?
Could you send me your config and html as an example if this question is allowed?

Many thanks for your replies and help!!!
Photo of Lutz Neumeier

Lutz Neumeier

  • 8 Posts
  • 1 Reply Like
Ok. solved. Only problem seemed to have been Hydration. Without Hydration no problem!
Photo of Aabha Singh

Aabha Singh

  • 1 Post
  • 0 Reply Likes
Can you give me the solved code for the barcode scanner please
Photo of John Weidner

John Weidner, Champion

  • 435 Posts
  • 80 Reply Likes
in your index.html


<html>
<body>
<script>
function scan() {
cordova.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>
<div onclick="scan()"> Scan </div>
</body>
</html>


In your config.xml

<gap:plugin name="com.phonegap.plugins.barcodescanner" />