我对cordova和phonegap非常陌生。我需要安装Cordova插件条形码扫描器,我已尝试通过终端(mac)使用以下行:
cordova plugin add cordova-plugin-barcodescanner
,请参阅此document。
然而,我得到一个我无法解决的错误。我已经阅读了很多其他帖子,并且没有为我的案例找到解决方案。
我的错误:
(node:1721) UnhandledPromiseRejectionWarning: CordovaError: Cannot
find plugin.xml for plugin "cordova-plugin-barcodescanner". Please
try adding it again.
at new PluginInfo
(/usr/local/lib/node_modules/cordova/node_modules/cordova-
common/src/PluginInfo/PluginInfo.js:367:15)
at PluginInfoProvider.get
(/usr/local/lib/node_modules/cordova/node_modules/cordova-
common/src/PluginInfo/PluginInfoProvider.js:35:32)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-
lib/src/plugman/fetch.js:177:51
at _fulfilled
(/usr/local/lib/node_modules/cordova/node_modules/cordova-
lib/node_modules/q/q.js:787:54)
at self.promiseDispatch.done
(/usr/local/lib/node_modules/cordova/node_modules/cordova-
lib/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch
(/usr/local/lib/node_modules/cordova/node_modules/cordova-
lib/node_modules/q/q.js:749:13)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-
lib/node_modules/q/q.js:509:49
at flush (/usr/local/lib/node_modules/cordova/node_modules/cordova-
lib/node_modules/q/q.js:108:17)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:1721) UnhandledPromiseRejectionWarning: Unhandled promise
rejection. This error originated either by throwing inside of an
async function without a catch block, or by rejecting a promise
which
was not handled with .catch(). (rejection id: 1)
(node:1721) [DEP0018] DeprecationWarning: Unhandled promise
rejections
are deprecated. In the future, promise rejections that are not
handled
will terminate the Node.js process with a non-zero exit code.
这些是我的规格: iOS:10.13.4 Phonegap:0.4.5
谢谢! :)
答案 0 :(得分:0)
或
2.将<plugin name="cordova-plugin-barcodescanner" spec="0.7.4" />
设置为config.xml,然后尝试使用您的cmd运行cordova plugin add cordova-plugin-barcodescanner
。
如果不起作用,请尝试运行命令npm install cordova-plugin-barcodescanner
。 (如果您的命令已经将一些文件添加到插件文件夹中,请将其删除并再次运行。)
检查您尝试安装插件的路径,它必须类似于 C:/ Desktop / Application / www / plugin /
确保您的config.xml具有:
<config-file target="AndroidManifest.xml" parent="/*" mode="merge">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
</config-file>
答案 1 :(得分:0)
好的,经过很多天和试验,我想通了。 基本上我所做的是使用CLI从头开始创建一个新项目。然后我一步一步地跟着this documentation。当我进入&#34;插件&#34;部分,我用以下行添加了我想要的插件:
cordova plugin add cordova-plugin-barcodescanner
希望这有助于其他人。 干杯!