How to remove record audio and modify audio settings permission from media plugin

I am using media plugin for my hybrid app. But I don’t want some of the user permissions. It has four permissions in AndroidManifest.xml file -

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

But I don’t want record audio user permission and modify audio settings in user permissions. If I am commenting these user permissions in plugin.xml and AndroidManifest.xml file of media plugin and then also on building the project these permissions appear in AndroidManifest File.

1 Like

at the root of your project you should take a look at the following

android.json

plugins/android.json

See section

    "AndroidManifest.xml": {
            "parents": {
                "/*": [
                    {
                        "xml": "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />",
                        "count": 2
                    },
                    {
                        "xml": "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\" />",
                        "count": 1
                    },
                    {
                        "xml": "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\" />",
                        "count": 1
                    }
                ]
            }

Remove anything you don’t need from there

AndroidManifest.xml

Then - edit the file platforms/android/AndroidManifest.xml - and remove the matching permissions you previously removed

Rebuild

ionic build android

Notes

  1. Make sure the JSON is still valid after your changes
  2. Also note, remove the last comma “,” or you’ll receive an error SyntaxError: Unexpected token ] ( even tough the last comma in JSON validator is considered valid )
1 Like

Thanks, but aren’t those files overwritten sometimes ?

Is it possible to set the permissions from the config.xml file ?

not sure if it should be overwritten, but this is something I always do before I upload my apps to Google Play.
I remove it, build & upload the apk, so it works 100% for me … :smile:

You think it’s possible to do that from the dashboard of ionicjs ?

The AndroidManifest.xml is in the gitignore so ionic server take himself this androidmanifest and not mine :frowning: