BarcodeScanner issue

  • 1
  • Problem
  • Updated 5 years ago
  • Not a Problem
I want to show QR code scan. For that I need barcodeScanner plugin. The problem is that it installs the newer version but https://build.phonegap.com/apps here in the plugin section they said that version 2.2.0 is must. But such a version is not available. What should I do ?

Thanks
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Why is such version not available?
https://build.phonegap.com/plugins/2421
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
But when you install the barcodescanner plugin it come with the latest version(4.0.1).
You can check the GIT repository, you can't install 2.2.0 version.
Btw when you build barcodescanner app having the capability of scanning QR code, build.phonegap.com doesn't add it because it doesn't exists in npm.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
The PGB list of plugins is not maintained/updated anymore. See the blog posts on the topic.
The latest cordova barcodescanner plugin can be found at npm, though:
https://www.npmjs.com/package/cordova...
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
Yes sir, In installed new plugin but I need to specify the version on the config.xml so I specified it as 4.0.1 and when I tried to upload the project it says it not compatible with the version you're using.

Then I changed the version in config.xml to 2.2.0 and I compiled. But It's not working. The same code works perfectly if I use the android emulator.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
but I need to specify the version on the config.xml
Why would you need to do that? Wouldn't you prefer to have the latest version?
(Or is your problem not the barcode scanner at all, but rather another plugin, which claims a dependancy, or the pgb version that doesn't support the included plugin version?)

Anyway, you can't just include the npm version in your config.xml and then add a version number that doesn't exist for that particular plugin. Have you noticed the correct current version number for the npm barcode scanner plugin?
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
I have added plugin name in config.xml without specifying the version as you said,

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

I compiled and installed on my phone but still it doesn't work. It works perfectly when I used emulator's apk I mean compiled by eclipse.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
So, the app gets built and you have no messages in the plugin list anymore?
(If so, your initial problem seems to be solved).

Now, how "doesn't it work"?? Do you get any javascript errors? Do you see any unexpected results? Does it start at all? (If not, is the plugin activated and all objects present?) Is the scan output different from the screen image?
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
It works perfectly in the emulator and .apk generated by the emulator works perfectly on my physical phone, it opens scanner activity and everything works perfectly. Now when I compile it from build.phonegap.com and install it on the real phone device it doesn't work at all. When I click on the scan button it does nothing.

P.S I'm following this tutorial : http://sbzhouhao.net/2014/07/22/Phone...

Thank You !
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
OK.
Usually, that is an indication that something is wrong with the directory structure, the config.xml or the inclusion of phonegap.js
These three items are the major differences between local build and Phonegap Build.
In any way, you cannot upload your directory structure and config.xml exactly as prepared for a local build....that would almost always lead to a failing app.

- It would be helpful if you showed your config.xml and directory structure
- Can you confirm that you reference phonegap.js WITHOUT including such file in your assets?

So, the scanner doesn't start.
Is the plugin activated and all objects present? You can verify this by displaying the object type value of "cordova.plugins.barcodeScanner" and "cordova.plugins.barcodeScanner.scan", or simply the full structure of the barcodeScanner object.
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
Ok sir,
Correction: I'm using "com.phonegap.plugins.barcodescanner"

Where do I add phonegap.js? I have added cordova.js in my index.html. And where should I include phonegap.js ? You mean Do I need to attach while uploading zip on Phonegap Build ?

This the structure :http://prntscr.com/83d958

And how do I see the object of "com.phonegap.plugins.barcodescanner"

Thanks for your quick reply :-)
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. You should not upload your full project to PGB. See the PGB docs at http://docs.build.phonegap.com/en_US/ (Getting Started section)
2. config and index.html should be in the same directory
3. I did NOT suggest to look at object "com.phonegap.plugins.barcodescanner" , because that is no object. Instead, look into object "cordova.plugins.barcodeScanner" (as I wrote above)
You can do that the same way you displayed the full contacts object in yesterday's thread.
(use the toSource() method or go through the properties in a loop)
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
Sir I never uploaded the entire project. I just put the config.xml file into www folder and made zip of that files and uploaded to Phonegap Build.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Excuse me, but....what was that directory structure, then? Your local machine?
(Since we're talking PGB here, I thought the only relevant structure would be your zip file)
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
I have files on local machine and uploading to build.phonegap.com. I tested another app that is inAppBrowser. I installed the plugin and did everything still it doesn't work with PGB.
Here is my project files : https://dl.dropboxusercontent.com/u/4...
Please check the project structure and let me know.
Thank you.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Is this the zip file you are uploading to PGB, or is this a 17MB zip file of stuff that you have on your local PC?

If it's the zip file for PGB (which is the only relevant thing here), it is not valid for PGB. It contains your full project and not your assets. It has config and index.html not in the same (root) directory. And the config contains


-<feature name="InAppBrowser">
<param value="org.apache.cordova.inappbrowser.InAppBrowser" name="android-package"/>
</feature>
<plugin version="1" name="cordova-plugin-whitelist"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>
-<platform name="android">
<allow-intent href="market:*"/>
</platform>
-<platform name="ios">
<allow-intent href="itms:*"/>
<allow-intent href="itms-apps:*"/>
</platform>

which may be in PGB's master config file, but it's in error!

SUPPORT TEAM, PLEASE NOTE!!

It contains a feature element which you should remove.
It contains a PLUGIN element instead of GAP:PLUGIN elements
That plugin lacks the SOURCE (=npm) attribute
It contains PLATFORM elements that should be removed
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
Oh man! I sent you the full project. The part I used to make zip is this :
https://dl.dropboxusercontent.com/u/4...
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Oh great. :-)

Well, you should at least remove:
- AndroidManifest.xml
- plugins directory
- cordova.js
- cordova_plugins.js

Your config
- doesn't include a barcode scanner plugin
- contains wrong icon and splash paths (remove "www/")
- has the bottom part wrong (see previous comment)

Your index.html
- has the meta viewport tag commented out. Why?
- doesn't contain any scanner code (We are talking about a scanner problem, aren't we?)

...and I strongly recommend using lower case characters only for the widget ID value, and supplying the targeted Phonegap-Build-Version.
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
Yes sir. As you said I removed cordova.js, cordova_plugins.js, AndroidManifest.xml & plugins folder. Still it doesn't work. SQLITE database works fine but this barcodescanner doesn't work at all. I think it's not working because barcodescanner plugin has added activities for the scanning code in AndroidManifest.xml.
Kindly check my index file if you some time. :-)

Updated zip : https://dl.dropboxusercontent.com/u/4...

Thanks!
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
I notice you have references to both phonegap.js and cordova.js
What are you trying to achieve with that?
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
Oh sorry. When I created the project using phonegap create myapp cordova.js came automatically so I thought it is required.

Thanks man it worked now. :-)