简体   繁体   English

如何在基于phonegap的项目中添加cordova插件?

[英]How can I add a cordova plugin to a phonegap based project?

I've created a phonegap project, with the CLI : 我已经使用CLI创建了一个phonegap项目:

phonegap create Projectname

This works fine and I can start it without problems. 这工作正常,我可以毫无问题地启动它。 Now I want to add this Barcodescanner : https://github.com/wildabeast/BarcodeScanner . 现在,我要添加此Barcodescanner: https : //github.com/wildabeast/BarcodeScanner I did this some time ago in my cordova based project like this: 我前一段时间在我的Cordova项目中做到了这一点,如下所示:

 cordova plugin add https://github.com/wildabeast/BarcodeScanner.git 

Now I tried this with my Phonegap based project and it's obviously not working. 现在,我在基于Phonegap的项目中尝试了此操作,但显然无法正常工作。 But I've tried 但是我尝试过

phonegap local plugin add https://github.com/wildabeast/BarcodeScanner.git 

too, which is not working too... Now is there one more possibility to add plugins, and thats plugman, but I don't get the plugman syntax at all ... Could you tell me at first why the phonegap command is not working and how to add the plugin with plugman. 同样,它也不能正常工作...现在有更多的可能性可以添加插件,那就是plugman,但是我根本不了解plugman的语法...首先请您告诉我为什么phonegap命令不可用工作,以及如何使用Plugman添加插件。 Thanks a lot. 非常感谢。

The problem is the version from wildabeast is not compactible for phonegap version >3.2 问题是来自wildabeast的版本无法用于大于3.2的phonegap版本

Try adding this barcode scanner plugin,its specific to phonegap https://github.com/phonegap-build/BarcodeScanner 尝试添加此条码扫描器插件,它专用于phonegap https://github.com/phonegap-build/BarcodeScanner

Install it using the syntax 使用语法安装

phonegap local plugin add https://github.com/phonegap-build/BarcodeScanner

To get it to work I created a new project and copied my www to it and installed the plugin.It did not work for me in the old project.It might for you Iam not sure,just check 为了使它正常工作,我创建了一个新项目,并将我的www复制到该项目并安装了插件。在旧项目中,它对我不起作用。对于您来说我不确定,请检查一下

Why don't you try adding it manually? 您为什么不尝试手动添加它? Just copy the Java sources to the src folder, the JavaScript (if any) to the assets folder, then manualy add a plugin element in the /res/xml/config file . 只需将Java源代码复制到src文件夹,将JavaScript(如果有)复制到asset文件夹,然后在/res/xml/config file手动添加一个插件元素。 Make sure to add permissions (like camera, file access, etc) to the manifest if needed. 如果需要,请确保向清单添加权限(例如摄像机,文件访问权限等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM