Udgivet i Skriv en kommentar

Cordova – Android Remove unnecessary permissions

You have to open plugins/android.json, locate in that file part which looks like this.

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

After removal of  lines, make sure that android.json still be valid JSON file. Also please notice the count property which indicates how many plugins use the permissions. If you have value more then 1 you should find which other plugins could use that permission. Also I don’t sure that Cordova plugins was tested to be workable without proper permissions, so you on your own when removing permissions from that file.
If you put your system in the broken state, you always could remove all content of platforms and plugins folders and recreate your project by running.
Remember to remove permissions in AndroidManifest.xml to.

cordova create...
cordova platform add ...
cordova plugin add ...

Source:

Skriv et svar