I use CLI to build my Cordova app, and I have added the Media plugin.
\'cordova build\' automatically adds the android.permission.RECORD_AUDIO to my AndroidManifest.
A clone of Steve-e-b's answer for those who are more comfortable with python. It assumes the file will be located under something like hooks/after_prepare/123_remove_permissions.py
and be executable.
#!/usr/bin/env python
import os
script_dir = os.path.dirname(os.path.abspath(__file__))
project_dir = os.path.abspath(os.path.join(script_dir, '../..'))
bad_permissions = [
'WRITE_EXTERNAL_STORAGE',
'RECORD_AUDIO',
'MODIFY_AUDIO_SETTINGS',
]
android_manifest = os.path.join(project_dir, 'platforms/android/app/src/main/AndroidManifest.xml')
with open(android_manifest, 'r') as fr:
lines = fr.readlines()
new_lines = [line for line in lines if not [perm for perm in bad_permissions if perm in line]]
with open(android_manifest, 'w') as fw:
fw.writelines(new_lines)