How to edit AndroidManifest.xml in PhoneGap 3

2019-01-23 12:47发布

问题:

It seems PhoneGap generates that file automatically when config.xml is modified.

I wish to add Ad network's activities, services, etc in AndroidManifest.xml but I can't find the correct way to edit that file.

回答1:

Phonegap uses config.xml to create androidmanifest.xml when you add the android platform to a project. It is also modified when you add plugins and build the project (for example, it adds the required permission for the plugin).

But you can also manually edit the file in platforms/android/AndroidManifest.xml to add permissions, configure the activity or the application... it will not be lost when you rebuild your project.



回答2:

Typically this is found in the "res" directory ( - src - gen [Generated Java Files] - Android - Android Dependencies - Referenced Libraries - assets - bin - libs - res - AndroidManifest.xml - proguard-project.txt - project.properties) of course this is depending on what version of Cordova you are using. Typically most of these things are specified in the config.xml for newer Phonegap builds from my understanding which is why you don't need to include an AndroidManifest.xml file when using Phonegap Build. I would recommend trying Configap to edit the main config.xml and see if any of the settings/services you need to access are options. Configap can be found here!

forgot to mention I use Notepad++ to edit my .xml on the fly but you can also open in the sdk



回答3:

You probably want to check out cordova-custom-config.

It supports many extra settings in the cordova config.xml to customise the AndroidManifest.xml.

I'm using it to change the android:configChanges setting (adding uiMode to stop it from reloading when docking/undocking) and it works great.

The cordova-custom-config github page shows a full example with all supported options so it's very easy to setup.