I will start by saying that I am very new to Gradle, so I apologize if this has already been answered.
I\'m working on an Android application that uses an API key to
Similarly to the accepted answer, you could do it with string resources, if you didn't want to duplicate your manifests.
For example, if you had two flavors (flavor1 and flavor2) You'd end up w/ the following source sets.
app/
src/
main/
res/
values/strings.xml
flavor1Release/
res/
values/strings.xml
flavor1Debug/
res/
values/strings.xml
flavor2Release/
res/
values/strings.xml
flavor2Debug/
res/
values/strings.xml
You could then just use a string resource for your key value
One further optimization to keep all your keys in one place is to define them all in strings.xml in your main source set. and then have the flavor/build source sets reference those.
for example:
flavor1ReleaseKey
flavor1DebugKey
flavor2ReleaseKey
flavor2DebugKey
then in each of your flavor/build sourceSets, you just reference those keys.
flavor1Release/res/values/strings.xml
@string/flavor1ReleaseKey