Build Android with Gradle (Build Type + Product Flavor = Build Variant)

Product flavors

app/build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
android {
....

productFlavors {
pro {
...
}

free {
...
}
}
}

Build Type + Product Flavor = Build Variant

  • pro - debug
  • pro - release
  • free - debug
  • free - release

Sourcesets and Dependencies

  • android.sourceSets.pro
    Location src/pro/
  • android.sourceSets.androidTestPro
    Location src/androidTestPro/
  • android.sourceSets.proDebug
    Location src/proDebug/
  • android.sourceSets.proRelease
    Location src/proRelease/
  • android.sourceSets.androidTestPro
    Location src/androidTestPro/

Building and Tasks

  1. assemble<Variant Name>
  2. assemble<Build Type Name>
  3. assemble<Product Flavor Name>

    Build single variant

    assembleProDebug

    Build all given Build Type

    proDebug

    freeDebug

    assembleDebug

    Build all given flavor

    proRelease

    proDebug

    assemblePro

    Build all variants

    assemble

dependencies {
    androidTestProCompile "..."
}