Skip to content

Instantly share code, notes, and snippets.

Created May 22, 2018 02:01
  • Star 21 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Airbnb Gradle Flavors
apply from: './flavors.gradle'
android {
buildTypes {
productFlavors {
project.flavors.each { flavor, config ->
"$flavor" {
dimension 'scope'
if (flavor != 'full') {
versionNameSuffix ".$flavor"
class FlavorOptions {
final String entryModule
FlavorOptions(String entryModule) {
this.entryModule = entryModule
project.ext.flavors = [
full: new FlavorOptions(":flavor.full"),
foo: new FlavorOptions("")
Copy link

ivanalvarado commented Apr 24, 2021

Been trying to piece these snippets together along with this talk, but I still have a few questions:

1. Are the feature flavors application or library modules?

I keep running into build errors when they're modules. Specifically:

Execution failed for task ':app:processFlavorDebugResources'.
A failure occurred while executing$ActionFacade

Error goes away when I change the module to a

2. Noticed your response on your Medium article.

This snippet adds the entry module as a dependency of the root app module:

project.flavors.each { flavor, config ->
    project.dependencies.add("${flavor}Compile", project(config.entryModule))

I assume the snippet above goes in the app/build.gradle file?

3. What actually lives in a flavor module?

From your response to this, each flavor has its own Application class. And from Ben's talk, a LauncherActivity and some UI configurations. Am I missing anything else? Does each flavor gradle file also perform some flavor configuration or does that solely live in app/build.gradle?

A detailed example of this set up would be greatly beneficial.

Copy link

gpeal commented Apr 25, 2021

@ivanalvarado Hi Ivan, unfortunately, I don't work at Airbnb anymore and don't have access to the latest code. Every time I work with gradle, it requires a lot of trial and error and Googling (you are not alone) so I won't be able to provide more specific code either.

I belive this code was at the project level app.gradle file though and flavors are used for application modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment