Android Gradle:重命名/禁用默认构建类型 [英] Android Gradle: rename/disable default build type

查看:149
本文介绍了Android Gradle:重命名/禁用默认构建类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

预定义的构建类型可以以某种方式重命名吗?

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

我们使用一些表示内部暂存设置(DEV/TEST/LIVE)的自定义构建类型,而不需要buildTypes(发行版/调试)中的构建.可以在调用 assemble 时以某种方式重命名或禁用这些功能吗?

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?

推荐答案

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

请注意,Android Studio首次导入项目时会选择任何

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.

这篇关于Android Gradle:重命名/禁用默认构建类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆