Skip to content

Instantly share code, notes, and snippets.

@hdodov
Last active July 15, 2021 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hdodov/7db6e20f19fa8240b30a3c8b3b3af8ea to your computer and use it in GitHub Desktop.
Save hdodov/7db6e20f19fa8240b30a3c8b3b3af8ea to your computer and use it in GitHub Desktop.
How to completely remove an Android permission from Cordova app.

In this example, I'll show how to remove the RECORD_AUDIO permission.


  1. Navigate to the plugins directory in your Cordova folder.

  2. Open the plugin.xml file of each plugin and search for something like:

<uses-permission android:name="android.permission.RECORD_AUDIO"/>
  1. If you don't find anything like it, that plugin doesn't use the permission. If you do find it, remove it.

  2. Navigate to:

yourCordovaFolder\platforms\android
  1. Open a file, called android.json.

  2. Search for code that looks like this:

"AndroidManifest.xml": {
    "parents": {
        "/*": [
            {
                "xml": "<uses-permission android:name=\"android.permission.RECORD_AUDIO\" />",
                "count": 1
            },
            {
                "xml": "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />",
                "count": 1
            }
        ]
    }
}
  1. Remove the RECORD_AUDIO part so that you're left with this:
"AndroidManifest.xml": {
    "parents": {
        "/*": [
            {
                "xml": "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />",
                "count": 1
            }
        ]
    }
}

Note: Be careful to preserve proper JSON syntax!

  1. Go to:
yourCordovaFolder\platforms\android
  1. Open a file, called AndroidManifest.xml.

  2. Remove something that looks like this:

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

Conclusion

When you build your app, the permission should be gone. You can always check the AndroidManifest.xml file. If it's there, your app uses it. The reason you have to remove it from the plugin.xml files and android.json is because if it's there, Cordova automatically adds it to AndroidManifest.xml upon building.

@riecha24
Copy link

Thanks! Helped me a ton!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment