Optimization

Added in 7.3.0

@Incubating
interface Optimization


DSL object for configurations aimed for optimizing build process(e.g. speed, correctness). This DSL object is applicable to buildTypes and productFlavors.

Summary

Public functions

Unit

Configure baseline profile properties

Unit

Configure keep rules inherited from external library dependencies

Public properties

Boolean

Specifies whether to enable code shrinking and resource optimization.

SetProperty<String>

Specifies what packages are included for optimization.

Public functions

baselineProfile

Added in 8.2.0
@Incubating
fun baselineProfile(action: BaselineProfile.() -> Unit): Unit

Configure baseline profile properties

keepRules

Added in 7.3.0
@Incubating
fun keepRules(action: KeepRules.() -> Unit): Unit

Configure keep rules inherited from external library dependencies

Public properties

enable

Added in 8.13.0-alpha03
var enableBoolean

Specifies whether to enable code shrinking and resource optimization. Property works for applications only. For other types it will be ignored

By default, value is false to avoid runtime issue. When enabled the Android plugin uses R8 for optimization.

Flavours merge this property with "or" rule. That means having this enable=true sticks.

packageScope

Added in 8.13.0-alpha03
val packageScopeSetProperty<String>

Specifies what packages are included for optimization. Those may be local code packages and external libraries packages. You can include

  • classes for a single package, like "com.example.app.*"

  • classes from package and all subpackages, like "androidx.**"

  • everything "**"

Default (convention) value is "**"