28

I am in need to add some tags to the AndroidManifest.xml file which is found under

platforms\android\AndroidManifest.xml

As I have read the AndroidManifest.xml file gets generated on the fly and it is not advisable to edit it.

So is there a plugin that I can use that will modify the AndroidManifest.xml file for me with the values that I give it in the config.xml file?

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
krv
  • 2,830
  • 7
  • 40
  • 79

3 Answers3

37

Since the recent release of cordova@6.4.0 you can use the <edit-config> tag in config.xml to do this without requiring a 3rd party plugin. For example:

<edit-config file="AndroidManifest.xml" target="/manifest/uses-sdk" mode="merge">
    <uses-sdk android:minSdkVersion="16" android:maxSdkVersion="23" />
</edit-config>
DaveAlden
  • 30,083
  • 11
  • 93
  • 155
  • 1
    Though this is a good answer, and probably the best way to do it for 99% of circumstances I'd like to add a caveat. We use https://github.com/EddyVerbruggen/Custom-URL-scheme , it adds an intent to the AndroidManifest.xml. Using Results in the intent being removed - you might need to find a different strategy – Keith Paul Barrow Nov 30 '18 at 09:33
  • 6
    @KeithPaulBarrow In order to modify the attribute on ``, you can alternatively use [cordova-custom-config](https://github.com/dpa99c/cordova-custom-config): ``. This will not override changes made by other plugins. – DaveAlden Nov 30 '18 at 09:46
  • @DaveAlden - thanks, this is what we did. It's a pity we needed to do this, as it's always good to drop a dependency, but needs must. – Keith Paul Barrow Nov 30 '18 at 10:24
  • 1
    for me I had to use tag: – Wrong Mar 05 '19 at 10:22
5

in my case, nothing was working but this one i came up with:

<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest">
            <application android:hardwareAccelerated="false" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" />
        </edit-config>
Miguel
  • 3,349
  • 2
  • 32
  • 28
1

There is a plugin for that:

https://www.npmjs.com/package/cordova-custom-config

By using this plugin you can modify all the platform specific things (iOS and Android) and you get a clean cordova envirement.

Joerg
  • 3,102
  • 2
  • 24
  • 30