从 CLI 构建时,Cordova 向 AndroidManifest.xml 添加了不需要的权限 [英] Cordova adds unwanted permission to AndroidManifest.xml when building from CLI

查看:32
本文介绍了从 CLI 构建时,Cordova 向 AndroidManifest.xml 添加了不需要的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 CLI 构建我的 Cordova 应用程序,并添加了媒体插件.

I use CLI to build my Cordova app, and I have added the Media plugin.

'cordova build' 会自动将 android.permission.RECORD_AUDIO 添加到我的 AndroidManifest.xml 中,即使我没有使用该权限.

'cordova build' automatically adds the android.permission.RECORD_AUDIO to my AndroidManifest.xml even though I don't use that permission.

那么我该如何删除它呢?每次我构建发布时,权限都会添加到 apk 中.

So how do I remove it? Each time I build to release, the permission is added to the apk.

推荐答案

在你的项目中,编辑文件 plugins/org.apache.cordova.media/plugin.xml你会看到android特定的配置

In your project, edit the file plugins/org.apache.cordova.media/plugin.xml You'll see the android specific configuration

   <platform name="android">
        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="Media" >
                <param name="android-package" value="org.apache.cordova.media.AudioHandler"/>
            </feature>
        </config-file>

        <config-file target="AndroidManifest.xml" parent="/*">
            <uses-permission android:name="android.permission.RECORD_AUDIO" />
            <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
            <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        </config-file>
...

删除<uses-permission android:name="android.permission.RECORD_AUDIO"/>这样的行,每次构建时都不会添加权限.

remove the line <uses-permission android:name="android.permission.RECORD_AUDIO" />like this the permission will not be added each time you build.

由于该权限已经添加到 AndroidManifest.xml 中,您必须手动将其删除,然后下次构建时不应再返回.

As the permission has already been added to AndroidManifest.xml, you'll have to remove it manually and then it should not come back next time you build.

这篇关于从 CLI 构建时,Cordova 向 AndroidManifest.xml 添加了不需要的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆