Android Studio - Assigning multiple value to ManifestPlaceholders in Gradle

Viewed 18540

I have two environment of my project one Prod another one is Staging. So whenever I have to build any of the environment, I have to change multiple keys like map key, label name and other things in manifest. So I have searched and find out some of the solutions and manifestPlaceholders is one of them.

Now what I want to do is to assign multiple value in manifestPlaceholders. So can I put multiple values in it and yes then how to put multiple values in it. Here is the code for the manifestPlaceholders

buildTypes {
    debug {
        manifestPlaceholders = [ google_map_key:"your_dev_key"]
    }
    release {
        manifestPlaceholders = [ google_map_key:"prod_key"]
    }
}
4 Answers

I could not use the suggested approaches in other answers because gradle seems to have changed the type of manifestPlaceholders to val mutablemap in a recent release.

This was the only fix that worked for me:

manifestPlaceholders["key"] = "value0"
manifestPlaceholders["key"] = "value1"
Related