how can I use Android dexOptions?

爱⌒轻易说出口 提交于 2019-11-30 08:20:40
wyverny

boolean incremental

Whether to enable the incremental mode for dx. This has many limitations and may not work. Use carefully.

String javaMaxHeapSize

Sets the -JXmx* value when calling dx. Format should follow the 1024M pattern.

boolean jumboMode

Enable jumbo mode in dx (--force-jumbo).

boolean preDexLibraries

Whether to pre-dex libraries. This can improve incremental builds, but clean builds may be slower.

These can be found here:
http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.DexOptions.html

Hesam

set incremental to true.

This is experimental feature that is disabled by default. However you can enable it. I personally didn't noticed any changes in term of speed (if it affect the speed).

More explanation can be found there https://stackoverflow.com/a/24224385/513413.

Parth Patel

Example:

dexOptions {
    preDexLibraries = false
    incremental true
    javaMaxHeapSize "12g"
}

afterEvaluate {
    tasks.matching {
      it.name.startsWith('dex')
    }.each { dx ->
      if (dx.additionalParameters == null) {
          dx.additionalParameters = ['--multi-dex']
      } else {
          dx.additionalParameters += '--multi-dex'
      }
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!