h2015 h2015 - 4 months ago 100x
Android Question

How to control [Android] permissions with Phonegap?

Sorry for the length of this. Please read on.

How can I configure phonegap's project files so that either

phonegap platform add
phonegap build
generate APK (or intermediate files that are used to generate APK) without any permissions, while not touching any of the
files manually?

Below describes what I tried.

I'm using the latest Phonegap and I'm trying to use CLI (so, not Adobe's build service). I went through everything that I could find online (documentation, forums, here) trying to find at least some hints on how to control the build process, preferably via config (specifically for Android), so that files in
) get assembled the way that I want.

For example, even with all plugins removed (
phonegap plugin remove [plugin name]
+ manually removed
element from
, resulting in nothing but an empty json object in
), I can't get
to get created without these 3:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

I'd really not like to get into the discussion of why I'm trying to remove all permissions without manually changing
. I previously used Visual Studio Cordova project template, and I was able to make this work (it's got a different file merge/replacement system, equivalent of which I'm trying to discover on Phonegap side). Both Phonegap and Cordova documentation in general are very selfish/basic, IMO (but, that's another topic).

Of course, I've been removing/re-adding android-platform via
phonegap platform remove/add android
phonegap build android
each time after config change attempts (which I tried within
; I also tried to find a spot in the folder tree to place
that would replace the one in
), but nothing worked. I've been verifying success/failure of my mission via
aapt d permissions "platforms\android\build\outputs\apk\android-debug.apk"
, and by manually checking generated
, and - no kidding - by release-bulding + signing + uploading to my Google account for their report of my APK (by that was before I discovered

If anyone can share some links, samples, book titles, or similar - I'd be grateful.

Thank you.


Nevermind. I concluded that there probably isn't 100% support for generating configuration for individual platforms, and that each one of those need to be edited manually. In other words, it's likely that some parts of /platforms/android/AndroidManifest.xml cannot be affected via /config.xml (it's a shame that there's no documentation talking about this; only few guides with few specific examples). Sure, I am aware of existence of hooks, but I'm not in the mood at the moment to start spending significant time to write code that would help me write code: I'll rather manually tweak AndroidManifest.xml (or, whatever), version-control it, and be done with it.