简体   繁体   English

Phonegap Android 权限、config.xml 和插件

[英]Phonegap Android permissions, config.xml and plugins

I have a Phonegap app that I'm currently developing and testing for Android.我有一个 Phonegap 应用程序,我目前正在为 Android 开发和测试它。 Problem is, when I publish to device, the Android Manifest is full of permission requests that I did not ask for.问题是,当我发布到设备时,Android 清单中充满了我没有要求的权限请求。

I have already figured out that the Phonegap Plugins (see this docs page under "Add features") have something to do with it.我已经发现 Phonegap 插件(请参阅“添加功能”下的此文档页面)与它有关。 If you install a plugin like Camera, then PhoneGap will automatically add the related permission to AndroidManifest.如果安装了Camera这样的插件,PhoneGap会自动将相关权限添加到AndroidManifest中。 So I've uninstalled all Phonegap Plugins that I didn't need, and those permissions went away.所以我卸载了所有不需要的 Phonegap 插件,这些权限也消失了。

So far so good.到现在为止还挺好。

Trouble is, my Android Manifest (and a file called "android.json" in the project's /Plugins directory) still contain a number of unwanted features:问题是,我的 Android 清单(以及项目 /Plugins 目录中名为“android.json”的文件)仍然包含许多不需要的功能:

<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Since my app is about budgeting, a "Record video" permission would suggest to any sane user that this is an evil sneaky app trying to destroy their privacy.由于我的应用程序是关于预算的,“录制视频”权限会向任何理智的用户表明这是一个试图破坏他们隐私的邪恶的偷偷摸摸的应用程序。

How do I get rid of these feature requests?如何摆脱这些功能请求? I already tried...我已经试过了...

  1. Adding <preference name="permissions" value="none" /> to config.xml.<preference name="permissions" value="none" />到 config.xml。
  2. Uninstalling all related Phonegap Plugins.卸载所有相关的 Phonegap 插件。 I even uninstalled a plugin AudioHandler that seems to have come preinstalled when I created the project.我什至卸载了一个插件 AudioHandler,它似乎是在我创建项目时预装的。

Of course I can remove the stuff manually from AndroidManifest.xml before I publish my final version.当然,我可以在发布最终版本之前从 AndroidManifest.xml 中手动删除这些内容。 But I would like a more structural solution, since I use "cordova run android" to test on device, and this overwrites all changes to AndroidManifest.xml and android.json.但我想要一个更结构化的解决方案,因为我使用“cordova run android”在设备上进行测试,这会覆盖对 AndroidManifest.xml 和 android.json 的所有更改。

Are you sure you removed all plugins?你确定你删除了所有插件? ( use phonegap plugin list ) to see what plugins there are. use phonegap plugin list )查看有哪些插件。

I Am not sure whether there is any difference, but I use我不确定是否有任何区别,但我使用

phonegap run android

in stead of代替

cordova run android

according to the docs the run command do both clean and build... so cleaning should be done.. (actually I use the -V command to get some extra debug info)根据文档,运行命令同时执行清理和构建......所以应该完成清理......(实际上我使用 -V 命令来获取一些额外的调试信息)

I also had a lot of troubles by the way, see: Upgrade to phonegap 3.3.0顺便也遇到了很多麻烦,见: 升级到phonegap 3.3.0

And starting with an empty platforms folder is one of my tries.... than you should be sure it completely rebuild your manifest file....从一个空的平台文件夹开始是我的尝试之一......比你应该确保它完全重建你的清单文件......

Edit 29-1-2014编辑 29-1-2014

By the way, the best explanation of this CLI and phonegap 3.x issues can be found here: http://devgirl.org/2013/09/05/phonegap-3-0-stuff-you-should-know/顺便说一句,可以在此处找到此 CLI 和 phonegap 3.x 问题的最佳解释: http ://devgirl.org/2013/09/05/phonegap-3-0-stuff-you-should-know/

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

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