3

I already have

2 flavours (staging, production)

2 buildTypes (debug, release)

beyond that, I want to have different variants for, say, different vendors. like a production-release build for samsung and htc. is it possible through build scripts?

PS: I don't want to use 3rd party plugin like this

Community
  • 1
  • 1
Ankit
  • 6,554
  • 6
  • 49
  • 71
  • You've already created 2 flavors, I don't understand why can't you just use the same procedure to create other flavors? – Kai Apr 20 '15 at 12:28
  • @kai bcz its like a 3rd level of variant. its same as say, prod-release build, just that some branding parameters will be different for different vendors. I agree its possible through buildTypes, but for each vendor i'ld need 2 entries, though manageable but slight messy. – Ankit Apr 20 '15 at 12:32
  • I see what you mean now, but I don't think you really need a "staging-release" build? In that case you just need to define 3 build types (staging, production-debug, production-release), leaving flavors to be used exclusively for branding/customization purpose. That is what I did for one of my project and I can't complain about the setup. – Kai Apr 20 '15 at 12:39

1 Answers1

3

You could use flavor dimensions.

android {
    flavorDimensions 'environment', 'vendor'

    productFlavors {
        staging {
            flavorDimension 'environment'
        }

        production {
            flavorDimension 'environment'
        }

        htc {
            flavorDimension 'vendor'
        }

        samsung {
            flavorDimension 'vendor'
        }
    }
}
Mark Vieira
  • 13,198
  • 4
  • 46
  • 39