How to inject the value of "tools:node" in Android Manifest file from Gradle

Viewed 207

I'm work on an App-generator and I need to customize the Manifest elements.

I wanna remove some elements in my Manifest file by "tools:node=remove" but the value of "tools:node" comes from Gradle file !

I define this value in Gradle file :

    def hasWidget = "${Boolean.valueOf(System.env.hasWidget ?: true)}"
    manifestPlaceholders = [ appWidget : "${hasWidget ? "replace" : "remove"}"]

And in the Manifest file I try this :

        <receiver
        android:name="..."
        tools:node="${appWidget}"
        android:label="....">

But it did n't work !

It shows me an error : Click to check

Any Idea how can I pass this issue ?

I appreciate your help

1 Answers

Try updating your gradle-script to this:

    def hasWidget = "${Boolean.valueOf(System.env.hasWidget ?: true)}"
    manifestPlaceholders = [ appWidget : hasWidget ? "replace" : "remove" ]
Related