Skip to content

Instantly share code, notes, and snippets.

@zawadz88
Last active September 11, 2018 07:42
Show Gist options
  • Select an option

  • Save zawadz88/82b8ccbd7c4d3915ae6b4021bfe1c2f6 to your computer and use it in GitHub Desktop.

Select an option

Save zawadz88/82b8ccbd7c4d3915ae6b4021bfe1c2f6 to your computer and use it in GitHub Desktop.
Shared flavor config
ext.flavorConfig = { // 1
flavorDimensions "pricing"
productFlavors {
free {
dimension "pricing"
ext.myApplicationIdSuffix = '.free' // 2
}
paid {
dimension "pricing"
ext.myApplicationIdSuffix = '.paid'
}
}
productFlavors.all { flavor -> // 3
if (flavor.hasProperty('myApplicationIdSuffix') && isApplicationProject()) {
flavor.applicationIdSuffix = flavor.myApplicationIdSuffix
}
}
}
def isApplicationProject() { // 4
return project.android.class.simpleName.startsWith('BaseAppModuleExtension')
// in AGP 3.1.x with library modules instead of feature modules:
// return project.android instanceof com.android.build.gradle.AppExtension
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment