简体   繁体   English

Apache Cordova无法加载插件

[英]Apache Cordova unable to load a plugin

I am trying to create an app using apache cordova , i struggled to install it. 我正在尝试使用apache cordova创建一个应用程序,我很难安装它。 Finally, when everything worked just fine, i tried to add a plugin with this command : 最后,当一切正常时,我尝试使用此命令添加一个插件:

C:\hello>cordova plugin add org.apache.cordova.console

then this message appears : 然后出现此消息:

Fetching plugin "org.apache.cordova.console" via plugin registry

After a while an Error has appeared : 一段时间后出现错误:

Error: Failed to fetch package information for org.apache.cordova.console
at C:\Users\pc\AppData\Roaming\npm\node_modules\cordova\node_modules\plugman
\src\registry\registry.js:32:20
at Request.cb [as _callback] (C:\Users\pc\AppData\Roaming\npm\node_modules\c
ordova\node_modules\plugman\src\registry\registry.js:251:9)
at self.callback (C:\Users\pc\AppData\Roaming\npm\node_modules\cordova\node_
modules\plugman\node_modules\request\index.js:148:22)
at Request.EventEmitter.emit (events.js:117:20)
at ClientRequest.self.clientErrorHandler (C:\Users\pc\AppData\Roaming\npm\no
de_modules\cordova\node_modules\plugman\node_modules\request\index.js:257:10)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:415:13)   

Make sure that you have added atlest one platform inside the created cordova project. 确保已在创建的cordova项目中添加了至少一个平台。 Then try downloading directly from github through Command line interface(make sure your are inside the project director). 然后尝试通过命令行界面直接从github下载(确保您位于项目主管中)。

Eg:For console plugin 例如:对于控制台插件

cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git 科尔多瓦插件添加https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git

for other plugin github link is found in cordova documentation itself 在cordova文档本身中可以找到其他插件的github链接

http://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html http://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html

If the installation still fails.It means the plugin is deprecated for the cordova version you are using.In that case try upgrading cordova and then create a new project and repeat the same. 如果安装仍然失败,则说明该插件不适合您使用的cordova版本,在这种情况下,请尝试升级cordova,然后创建一个新项目并重复相同的操作。

To upgrade you can use the command 要升级,您可以使用以下命令

npm update -g cordova npm更新-g cordova

Another simple way is 另一个简单的方法是

  1. download the plugin as zip from git 从git下载zip插件
  2. extract the zip to some path 将zip解压缩到某个路径
  3. run cordova plugin add cordova-plugin-splashscreen-master ( replace 'cordova-plugin-splashscreen-master' with your folder name ) 运行cordova plugin add cordova-plugin-splashscreen-master (用您的文件夹名替换'cordova-plugin-splashscreen-master')

Ill suggest you an another method.Its long but it might get the job done. 病态的建议您使用另一种方法。虽然很长,但可能可以完成工作。

All plugins are available to download in github Example: 所有插件都可以在github中下载示例:

https://github.com/apache/cordova-plugin-splashscreen https://github.com/apache/cordova-plugin-splashscreen

Download the zip file. 下载压缩文件。

All plugin will fall into the plugin directory and into the structure define in rm command present in documentaion 所有插件都将落入plugin目录和documentaion中存在的rm命令中定义的结构中

example plugins/org.apache.cordova.core.splashscreen/www 示例plugins / org.apache.cordova.core.splashscreen / www

Manually create this structure and replace the downloaded www folder from github inside your plugins/org.apache.cordova.core.splashscreen/www 手动创建此结构,并从plugins / org.apache.cordova.core.splashscreen / www内部的github中替换下载的www文件夹

Manually add the feature in config.xml 在config.xml中手动添加功能

<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.SplashScreen" />
</feature>

Refer documentation. 请参阅文档。

http://cordova.apache.org/docs/en/3.0.0/cordova_splashscreen_splashscreen.md.html#Splashscreen http://cordova.apache.org/docs/en/3.0.0/cordova_splashscreen_splashscreen.md.html#Splashscreen

Build the app.It will work 编译应用程序,它将正常工作

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

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