Fabio Fabio - 1 year ago 45
Android Question

How to eliminate default build variants in android gradle

We have already different build variants in our project (dev,qa and others), making the default variants irrelevant and confusing.

Is there a way to completely remove the default build variants, namely

? They're already generating compiler errors that won't be fixed since they won't be supported anymore. I'd like them to be completely removed from existence.

If that's not possible I'd like to make most tasks that depend on them to be obsolete as if they never existed, like

It's ok to override a couple of tasks and generate nice error messages, but I'm afraid I'd end up overriding lots of tasks.

Answer Source

Putting these on build.gradle will make most if not all references to debug variant tasks to disapear.

android.variantFilter { variant ->
    if(variant.buildType.name.equals('debug') ) {

It's interesting to note though that if you have another variant based on debug it will still work. For example you can still run QA variant if you have it defined this way:

buildTypes {
    qa {
        initWith debug
        . . .