Reputation: 3
If I create 2 sub folders under SRC (eg- QA and PROD and put the google-services.json file), will that be enough? How will App understand which file to pick for qa/production version of app.
Upvotes: 0
Views: 221
Reputation: 15423
You are one step behind to achieve this. Just use productFlavors
for each build type in your module level build.gradle
.
// Specifies one flavor dimension.
flavorDimensions "version"
productFlavors {
PROD {
....
}
QA {
....
}
}
N.B: Check official document to learn more about build variant
Upvotes: 0
Reputation: 702
Look at using Application Flavours.
|--> app
|----> src
|------> main (this is where you 'base' product build goes
|--------> google-services.json (google services for main - Default)
|--------> res (res files for main - Default)
|------> qa (this is named the same as one of your flavours)
|--------> google-services.json (google services for qa)
|--------> res (res files for qa)
|----------> drawable-xxxhdpi (drawables for qa)
|----------> values (values files for qa, e.g. strings.xml)
|------> prod (this is named the same as one of your flavours)
|--------> google-services.json (google services for prod)
|--------> res (res files for prod)
|----------> drawable-xxxhdpi (drawables for prod)
|----------> values (values files for prod, e.g. strings.xml)
app build.gradle
...
flavorDimensions "main"
productFlavors {
qa {
applicationId = "com.your.appl.qa";
versionNameSuffix "_QA"
}
prod {
applicationId = "com.your.appl";
versionNameSuffix "_PROD"
}
}
...
You can then switch flavour in the Build Variants window:
Upvotes: 1