1

我想在 PhoneGap 项目中安装BarcodeScanner 插件。我已经阅读了存储库中的自述文件,它说必须使用 PlugMan 安装它,如下所示:

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.

当我从我的项目目录中运行以下命令时:

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
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

我究竟做错了什么?我应该将文件复制到项目目录中的某个目录吗?或者在使用plugman之前我应该​​运行任何其他命令吗?

4

2 回答 2

5

不知道这里出了什么问题,但我认为http://plugins.cordova.io上的插件是错误的。

您可以尝试从 git URL 安装,但至少对我来说(在使用 Cordova 3.5 的 Windows 上)这样做时会出现问题。

起作用的是以下(注意你需要安装 git):

git 克隆https://github.com/wildabeast/BarcodeScanner.git

Cd 到您的 Cordova 项目。

Cordova 插件添加InsertPath \BarcodeScanner

于 2014-05-31T14:18:05.273 回答
0

尝试通过添加 config.xml 文件:

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

然后尝试调用 API 函数。

于 2014-06-01T08:33:20.643 回答