简体   繁体   English

在产品风格中启用/禁用ProGuard

[英]Enable/disable ProGuard in the product flavor

So, I know that in the build type the runProguard 'bool' directive can be used to tell whether ProGuard should be run or not. 所以,我知道在构建类型中, runProguard 'bool'指令可用于判断ProGuard是否应该运行。 Unfortunately this directive does not work on the product flavors. 不幸的是,这个指令不适用于产品口味。 Is there any way to specify if ProGuard should or not run in the flavors? 有没有办法指定ProGuard是否应该在口味中运行? I have thought of using a configuration file which basically says "do nothing", but (1) I don't know what should I write in it to forbid ProGuard from doing absolutely anything and (2) I don't think it's a good solution. 我曾经想过使用一个基本上说“什么也不做”的配置文件,但是(1)我不知道我应该写什么来禁止ProGuard做任何事情和(2)我不认为它是好的解。

For your scenario, it feels like you are trying to model different phases of your development lifecycle. 对于您的场景,您感觉就像是在尝试为开发生命周期的不同阶段建模。 That's really where build types are for. 这就是构建类型的用武之地。 While Gradle (and hence Gradle for Android) ships with debug and release build types, you can define your own: 虽然Gradle(以及Gradle for Android)附带debugrelease版本类型,但您可以定义自己的:

buildTypes {
    debug {
      applicationIdSuffix ".d"
      versionNameSuffix "-debug"
    }

    release {
        signingConfig signingConfigs.release
    }

    mezzanine.initWith(buildTypes.release)

    mezzanine {
        applicationIdSuffix ".mezz"
        debuggable true
    }
}

Here, I: 我在这:

  • Configure the debug and release build types 配置debugrelease构建类型

  • Clone a mezzanine build type from release release克隆mezzanine构建类型

  • Override some settings on mezzanine , replacing what they had been defined as originally on release 覆盖mezzanine上的一些设置,替换它们在release最初定义的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM