Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. However, I can't find a way to reference the current buildType in the context of the dex options.

Something like this, is it possible?

android {
    ....
    dexOptions{
      if(buildType.name == 'debug') incremental = true
    }
}
like image 553
Nathan Schwermann Avatar asked Oct 20 '22 11:10

Nathan Schwermann


1 Answers

I believe I found a solution. Builds seem faster but I don't see any log messages to indicate incremental dex is working.

applicationVariants.all { variant ->
    if (variant.buildType.name == 'debug'){
        variant.dex.enableIncremental = true
        variant.dex.dexOptions.incremental = true
        variant.dex.dexOptions.preDexLibraries = true
    }
}
like image 196
Nathan Schwermann Avatar answered Oct 29 '22 00:10

Nathan Schwermann