Android 从项目中删除cordova插件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21932758/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:19:40  来源:igfitidea点击:

Removing cordova plugins from the project

androidcordovajenkins

提问by mmmm

Somehow in my app many of the cordova plugins are installed and because of that it requires access to almost everything - from my contacts to current location ( even though this app doesn't need this ).

不知何故在我的应用程序中安装了许多cordova插件,因此它需要访问几乎所有内容 - 从我的联系人到当前位置(即使这个应用程序不需要这个)。

This app is build via jenkins and as far as I understand one solution is to remove every plugin with single command, so it will be like:

这个应用程序是通过 jenkins 构建的,据我所知,一个解决方案是用一个命令删除每个插件,所以它会像:

cordova plugin rm org.apache.cordova.battery-status
cordova plugin rm org.apache.cordova.camera
cordova plugin rm org.apache.cordova.contacts
cordova plugin rm org.apache.cordova.geolocation
cordova plugin rm org.apache.cordova.media
cordova plugin rm org.apache.cordova.media-capture
cordova plugin rm org.apache.cordova.splashscreen
cordova plugin rm org.apache.cordova.vibration

But sometimes it shows some errors and with jenkins any error ends up with build failure, so is there any command which deletes all plugins? ( during installation basics plugins which requires any app to work are added automatically via cordova, so I was looking for some cordova plugin rm -allbut couldn't find it )

但有时它会显示一些错误,而对于 jenkins,任何错误都会导致构建失败,那么是否有任何命令可以删除所有插件?(在安装基础插件期间,需要任何应用程序才能工作的插件是通过cordova自动添加的,所以我正在寻找一些cordova plugin rm -all但找不到它)

回答by ruhanbidart

First, you should list your plugins:

首先,您应该列出您的插件:

cordova plugin list

With this result, you can simply do:

有了这个结果,你可以简单地做:

cordova plugin remove <PLUGIN_NAME>

For example:

例如:

cordova plugin remove org.apache.cordova.media

Hope it helps.

希望能帮助到你。

回答by JVE999

You can do it with bash as well (after switching to your Cordova project directory):

您也可以使用 bash 执行此操作(在切换到您的 Cordova 项目目录后):

for i in `cordova plugin ls | grep '^[^ ]*' -o`; do cordova plugin rm $i; done

回答by Hamid Tavakoli

You could use: cordova plugins list | awk '{print $1}' | xargs cordova plugins rm

你可以使用: cordova plugins list | awk '{print $1}' | xargs cordova plugins rm

and use cordova plugins listto verify if plugins are all removed.

并用于cordova plugins list验证插件是否已全部删除。

回答by DaveAlden

v2.0.0 of cordova-check-pluginsenables you to remove all plugins in a project:

cordova-check-pluginsv2.0.0使您可以删除项目中的所有插件:

$ npm install -g cordova-check-plugins
$ cordova-check-plugins --remove-all

It will attempt to use the Cordova CLI to remove each plugin, but if this fails it will force removal of the plugin from platforms/and plugins/.

它将尝试使用 Cordova CLI 删除每个插件,但如果失败,它将强制从platforms/和 中删除插件plugins/

If you also want to remove from config.xml, use:

如果您还想从 config.xml 中删除,请使用:

$ cordova-check-plugins --remove-all --save

Disclaimer: I am the author of cordova-check-plugins

免责声明:我是cordova-check-plugins的作者

回答by kuzyn

From the terminal (osx) I usually use

从我通常使用的终端(osx)

cordova plugin -l | xargs cordova plugins rm

Pipe, pipe everything!

管道,管道一切!

To expand a bit: this command will loop through the results of cordova plugin -land feed it to cordova plugins rm.

稍微扩展一下:此命令将循环遍历 的结果cordova plugin -l并将其提供给cordova plugins rm.

xargsis one of those commands that you wonder why you didn't know about before. See this tut.

xargs是您想知道为什么以前不知道的命令之一。看到这个啧啧。

回答by Matthew Purdon

I do it with this python one-liner:

我用这个 python one-liner 来做:

python -c "import subprocess as sp;[sp.call('cordova plugin rm ' + p.split()[0], shell=True) for p in sp.check_output('cordova plugin', shell=True).split('\n') if p]"

Obviously it doesn't handle any sort of error conditions, but it gets the job done.

显然它不处理任何类型的错误情况,但它完成了工作。

回答by osayilgan

As far as I remember from Cordova, you should have an xml file in "res" folder containing the list of plugins used in your project. You probably need to remove those unused plugins from list. And also you should remove related files.

就我在 Cordova 的记忆而言,“res”文件夹中应该有一个 xml 文件,其中包含项目中使用的插件列表。您可能需要从列表中删除那些未使用的插件。你也应该删除相关文件。

回答by user9972736

cordova platform rm android

cordova plugin rm cordova-plugin-firebase

cordova platform add android

回答by Hyman Shultz

This is the commandline for removing plugins in Cordova

这是在 Cordova 中删除插件的命令行

cordova plugin remove <pluginid>

cordova plugin remove <pluginid>

For example I ran cordova pluginand got a list of plugins then I used the id for the plugin to uninstall

例如,我运行cordova plugin并获得了一个插件列表,然后我使用插件的 id 来卸载

cordova plugin remove com.monday.contact-chooser

cordova plugin remove com.monday.contact-chooser

You can get help in the commandline by typing

您可以通过键入在命令行中获得帮助

cordova help <command>

cordova help <command>

回答by Nacho Marín

Scripts based on processing the list of installed plugins may not work as there are dependencies between installed plugins (e,g, cordova-plugin-file and cordova-plugin-file-transfer).

基于处理已安装插件列表的脚本可能无法工作,因为已安装插件之间存在依赖关系(例如,cordova-plugin-file 和 cordova-plugin-file-transfer)。

In the example, the script will find the file plugin first, then it will try to remove it and we'll get an error as file-transfer requires it. Therefore, we shall have

在这个例子中,脚本会首先找到文件插件,然后它会尝试删除它,我们会得到一个错误,因为文件传输需要它。因此,我们将有