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

Viewed 414

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.

2 Answers

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.

Add this text to the Widget tag at the top of your config.xml

i.e.

<widget id="com.mzbapps.serverlife" version="1.26.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:tools="http://schemas.android.com/tools">

Related