Installing a PhoneGap plugin: BarcodeScanner

自古美人都是妖i 提交于 2019-12-24 11:50:13

问题


I want to install the BarcodeScanner plugin in a PhoneGap project. I've read the Readme within the repository and it says that it must be installed with PlugMan like so:

Install a plugin
----------------

    $ plugman install --platform <platform> --project <directory> --plugin <plugin> [--variable NAME=VALUE]

Parameters:

 - platform <platform>: One of android, ios, blackberry10, wp7 or wp8
 - project <directory>: Path reference to a cordova-generated project of the platform you specify
 - plugin <plugin>: One of a path reference to a local copy of a plugin, or a remote https: or git: URL pointing to a cordova plugin (optionally append #branch:subdir) or a plugin ID from http://plugins.cordova.io
 - variable NAME=VALUE: Some plugins require install-time variables to be defined. These could be things like API keys/tokens or other app-specific variables.

When I run the following command from within my project directory:

cordova plugin add com.phonegap.plugins.barcodescanner

I get the following error response:

Fetching plugin "com.phonegap.plugins.barcodescanner" via plugin registry
Installing "com.phonegap.plugins.barcodescanner" for android
Error during processing of action! Attempting to revert...
Failed to install 'com.phonegap.plugins.barcodescanner':Error: Uh oh!
"/Users/Joel/Desktop/Sites/SampleProject/SampleProject/plugins/com.phonegap.plugins.barcodescanner/src/android/com.google.zxing.client.android.captureactivity.jar" not found!
    at Object.module.exports.common.copyFile (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/common.js:20:40)
    at Object.module.exports.common.copyNewFile (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/common.js:37:16)
    at module.exports.source-file.install (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/android.js:42:20)
    at Object.ActionStack.process (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/action-stack.js:47:25)
    at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:553:20)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:303:20
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:574:44
Error: Uh oh!
"/Users/Joel/Desktop/Sites/SampleProject/SampleProject/plugins/com.phonegap.plugins.barcodescanner/src/android/com.google.zxing.client.android.captureactivity.jar" not found!
    at Object.module.exports.common.copyFile (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/common.js:20:40)
    at Object.module.exports.common.copyNewFile (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/common.js:37:16)
    at module.exports.source-file.install (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/android.js:42:20)
    at Object.ActionStack.process (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/action-stack.js:47:25)
    at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:553:20)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:303:20
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:574:44
Joels-MacBook-Pro:UniSaver Joel$ cordova plugin add com.phonegap.plugins.barcodescanner
Fetching plugin "com.phonegap.plugins.barcodescanner" via plugin registry
Installing "com.phonegap.plugins.barcodescanner" for android
Error during processing of action! Attempting to revert...
Failed to install 'com.phonegap.plugins.barcodescanner':Error: Uh oh!
"/Users/Joel/Desktop/Sites/SampleProject/SampleProject/plugins/com.phonegap.plugins.barcodescanner/src/android/com.google.zxing.client.android.captureactivity.jar" not found!
    at Object.module.exports.common.copyFile (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/common.js:20:40)
    at Object.module.exports.common.copyNewFile (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/common.js:37:16)
    at module.exports.source-file.install (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/android.js:42:20)
    at Object.ActionStack.process (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/action-stack.js:47:25)
    at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:553:20)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:303:20
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:574:44
Error: Uh oh!
"/Users/Joel/Desktop/Sites/SampleProject/SampleProject/plugins/com.phonegap.plugins.barcodescanner/src/android/com.google.zxing.client.android.captureactivity.jar" not found!
    at Object.module.exports.common.copyFile (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/common.js:20:40)
    at Object.module.exports.common.copyNewFile (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/common.js:37:16)
    at module.exports.source-file.install (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/android.js:42:20)
    at Object.ActionStack.process (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/action-stack.js:47:25)
    at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:553:20)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:303:20
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:574:44

What am I doing wrong? Should I be copying files to a certain directory within my project directory? Or are there any other commands I should run before using plugman?


回答1:


Not sure what is wrong here, but I think the plugin on http://plugins.cordova.io is wrong.

You can try install from the git URL but at least for me (on windows with Cordova 3.5) something is broken when doing that.

What did work was the following (note you need to have git installed):

git clone https://github.com/wildabeast/BarcodeScanner.git

Cd to your Cordova project.

Cordova plugin add InsertPath\BarcodeScanner




回答2:


Try by adding in config.xml file :

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

Then try to call the API functions.



来源:https://stackoverflow.com/questions/23970387/installing-a-phonegap-plugin-barcodescanner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!