4

我想根据构建类型(发布、调试)执行一些代码。具体来说,我想根据构建类型更改 APK 名称......像这样,

if (buildType.name == 'release') {
  project.archiveBaseName = 'blah';
} else if (buildType.name == ...) {
  ...
}

但是,我不知道将这段代码放在哪里。我可以迭代构建类型,

android.buildTypes.each{ type ->
    print type.name
}

但这当然给了我所有的构建类型,而不是当前的构建类型。

4

1 回答 1

0

我想 buildTypes 是您需要的功能: http ://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Types

android {
    buildTypes {
        debug {
            packageNameSuffix ".debug"
        }
    }
}

它有帮助吗?

于 2014-02-17T14:00:05.817 回答