简体   繁体   English

根据buildtype android gradle启用dexoptions

[英]enable dexoptions based on buildtype android gradle

I want to use the incremental dex option but because its still experimental I only want it enabled when doing debug builds. 我想使用增量dex选项,但因为它仍然是实验性的我只想在进行调试构建时启用它。 However, I can't find a way to reference the current buildType in the context of the dex options. 但是,我找不到在dex选项的上下文中引用当前buildType的方法。

Something like this, is it possible? 这样的事情,有可能吗?

android {
    ....
    dexOptions{
      if(buildType.name == 'debug') incremental = true
    }
}

I believe I found a solution. 我相信我找到了解决方案。 Builds seem faster but I don't see any log messages to indicate incremental dex is working. 构建似乎更快,但我没有看到任何日志消息,表明增量dex正在工作。

applicationVariants.all { variant ->
    if (variant.buildType.name == 'debug'){
        variant.dex.enableIncremental = true
        variant.dex.dexOptions.incremental = true
        variant.dex.dexOptions.preDexLibraries = true
    }
}

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

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