2

Sorry for the length of this. Please read on.

How can I configure phonegap's project files so that either phonegap platform add or phonegap build generate APK (or intermediate files that are used to generate APK) without any permissions, while not touching any of the /platform/android/ 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 /platforms/android/ (e.g. AndroidManifest.xml) get assembled the way that I want.

For example, even with all plugins removed (phonegap plugin remove [plugin name] + manually removed <plugin element from /config.xml, resulting in nothing but an empty json object in /plugins/fetch.json), I can't get AndroidManifest.xml 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 /platform/android/AndroidManifest.xml. 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 /config.xml; I also tried to find a spot in the folder tree to place AndroidManifest.xml that would replace the one in /platform/android), 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 /platforms/android/AndroidManifest.xml, and - no kidding - by release-bulding + signing + uploading to my Google account for their report of my APK (by that was before I discovered aapt.exe).

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

Thank you.

Hari Lubovac
  • 622
  • 4
  • 14
  • INTERNET permission is required to use the android webview. Other permissions are required by different plugins you install – jcesarmobile Jan 08 '16 at 11:11
  • That can't be true: I have a Cordova-based app at Google Play with zero permissions, so not even webview usage mandates that (of course, my app can't make outbound calls). All files from www folder can be accessed just fine, even via file/media plugins (and, no permissions whatsoever). This tells me that plugins list/add all permissions/groups that relates to their full functionality, but that doesn't mean that the app is using all their functionality and gets to be forced to request all those permissions. So, I simply removed them from the manifest file, before bulding apk. – Hari Lubovac Jan 09 '16 at 16:17
  • You are right, I've just deleted all the permissions on a sample app and it was still working. I tried this years ago (phonegap 2.x.x) and the app crashed without the INTERNET permission, but it should be a bug. I've seen a plugin to write on the AndroidManifest.xml from the config.xml, but just write, it doesn't delete values. – jcesarmobile Jan 09 '16 at 23:40

1 Answers1

2

Add:

xmlns:android="http://schemas.android.com/apk/res/android"

to widget declaration in config.xml.

Then add the following:

<platform name="android">
    <config-file target="AndroidManifest.xml" parent="/manifest">
        <uses-permission android:name="android.permission.RECORD_AUDIO" />
    </config-file>
</platform>

Hope it helps!

General Failure
  • 2,421
  • 4
  • 23
  • 49
miche.atucha
  • 131
  • 2
  • 9