Search code examples
androidcordovaandroid-manifest

how to set tools namespace with <edit-config> in android manifest


I haven't succeeded in setting the tools namespace on my Cordova app's manifest file. The correct way to do this is to use the <edit-config> tag in the config.xml, like this:

        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest">
            <manifest xmlns:tools="http://schemas.android.com/tools" />
        </edit-config>

. I then use it to modify a <uses-permission> tag like this:

        <config-file parent="/manifest" target="app/src/main/AndroidManifest.xml" >
            <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="replace" />
        </config-file>

But I keep getting this error:

The prefix "tools" for attribute "tools:node" associated with an element type "uses-permission" is not bound.

Any ideas for how to do this? Thanks a lot in advance.


Solution

  • I've had little success with the built in functionality but good success with this plugin: https://github.com/dpa99c/cordova-custom-config

    The purpose of this plugin is to enable manipulation of native platform configuration files that are not supported out-of-the-box by Cordova/Phonegap CLI. The plugin uses hook scripts to update iOS and Android platform configuration files based on custom data defined in config.xml.