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?

3 Answers 3

37

Since the recent release of [email protected] 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>
4
  • 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 github.com/EddyVerbruggen/Custom-URL-scheme , it adds an intent to the AndroidManifest.xml. Using <edit-config file="AndroidManifest.xml" target="/manifest/application/activity" mode="merge"> <activity android:configChanges="keyboardHidden" /> </edit-config> Results in the intent being removed - you might need to find a different strategy Commented Nov 30, 2018 at 9:33
  • 6
    @KeithPaulBarrow In order to modify the attribute on <activity>, you can alternatively use cordova-custom-config: <custom-preference name="android-manifest/application/activity/@android:configChanges" value="keyboardHidden" />. This will not override changes made by other plugins.
    – DaveAlden
    Commented Nov 30, 2018 at 9: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. Commented Nov 30, 2018 at 10:24
  • 1
    for me I had to use <config-file> tag: <config-file parent="/manifest" target="AndroidManifest.xml">
    – Wrong
    Commented Mar 5, 2019 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>
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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.