Search code examples
androidgradleandroid-gradle-pluginandroid-build

Android Gradle: rename/disable default build type


Can the pre-defined build-types somehow being renamed?

We use some custom build types that represent our internal staging setup (DEV/TEST/LIVE) and do not need the build in buildTypes (release/debug). Can these somehow being renamed or disabled when calling assemble?


Solution

  • import com.android.builder.core.BuilderConstants
    android.variantFilter { variant ->
        def build = variant.buildType.name
        if (build == BuilderConstants.DEBUG || build == BuilderConstants.RELEASE) {
            variant.setIgnore(true)
        }
    }
    

    Note that the very first time importing the project Android Studio will pick any variant named debug else it will pick the first build variant in alphabetical order, which may not be the one you prefer as the default.