Android Studio : How to remove/filter build variants for default debug and release buildTypes and keep only those using custom buildTypes? Android Studio : How to remove/filter build variants for default debug and release buildTypes and keep only those using custom buildTypes? android android

Android Studio : How to remove/filter build variants for default debug and release buildTypes and keep only those using custom buildTypes?


Figured it out. It was a really silly mistake on my part. The above variant filter does work. The names are all lower case and the upper case in the strings i was comparing with were the culprit.

Changing to the following (making compare strings lower case) made it work as expected:

android.variantFilter { variant ->    if(variant.buildType.name.endsWith('release') || variant.buildType.name.endsWith('debug')) {        variant.setIgnore(true);    }}

or this

android.variantFilter { variant ->    if(variant.buildType.name.equals('release') || variant.buildType.name.equals('debug')) {        variant.setIgnore(true);    }}


If u want exclude by name use something like this

android.variantFilter { variant ->    if(variant.name.equals("qaRelease")|| variant.name.equals('something')) {        variant.setIgnore(true);    }}


If you want to ignore specific build variant , Here is details for understanding.

flavorDimensions "client", "server"productFlavors {    client1 {        manifestPlaceholders variant : 'Client 1'        dimension "client"        applicationId "com.edupointbd.bb"    }    client2 {        manifestPlaceholders variant : 'Client 2'        dimension "client"        applicationId "com.edupointbd.bb"    }    dev {        dimension "server"    }    staging {        dimension "server"    }    production {        dimension "server"    }}variantFilter { variant ->    def names = variant.flavors*.name    // To check for a certain build type, use variant.buildType.name == "<buildType>"    if (names.contains("client1") && names.contains("production")) {        // Gradle ignores any variants that satisfy the conditions above.        setIgnore(true)    }}