什么是增量,preDexLibraries,jumboMode,在 dexOptions 里面? [英] What's the meaing of: incremental, preDexLibraries, jumboMode, inside dexOptions?

查看:177
本文介绍了什么是增量,preDexLibraries,jumboMode,在 dexOptions 里面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 build.gradle 中我们可以添加参数

inside build.gradle we can add that params

android {
    dexOptions {
        incremental 
        preDexLibraries
        jumboMode 
        javaMaxHeapSize
    }
}

但文档太少

http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.DexOptions.html#com.android.build.gradle.internal.dsl.DexOptions

布尔增量

是否为dx启用增量模式.这有很多限制,可能行不通.小心使用.

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

布尔 jumboMode

boolean jumboMode

在 dx (--force-jumbo) 中启用巨型模式.

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

布尔值 preDexLibraries

boolean preDexLibraries

是否要预 dex 库.这可以改进增量构建,但干净构建可能会更慢.

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

1) 哪些限制是增量的?

1) which limitations are in incremental?

2) 什么是巨型模式?

2) what is jumbo mode?

3) 什么是 pre-dex 库?

3) what is pre-dex libraries?

推荐答案

首先让我们看看 dex 文件是什么.在纯java中,当你编译java代码时,它会被编译成一个.class文件,而在android中你的java代码将被编译成.dex文件.(两者都是字节码但不同)

first of all lets see whats dex file. in pure java when you compile the java code,it will be compiled into a .class file while in android your java code will be compiled into .dex file. (both are bytecodes but different)

incremental:这意味着 Gradle 将使用以前的 dex 文件并将新的更改附加到它们(不是每次都重新构建它们).

incremental: it means Gradle will use previous dex file and appends the new changes to them (not building them again every time).

你的第一个问题的答案:例如限制之一是您不能将它与 multidex* 一起使用(尽管此限制已解决 - 对于 sdk 版本,通过仅重建受影响的 dex 文件,可以对 multidex apk 进行 21+ 增量构建)

the answer of your first Q: e.g. one of the limitation were you couldnt use it along with multidex* (though this limitation was solved - for sdk versions 21+ incremental builds are possible for multidex apks by rebuilding only the affected dex files)

-注意:您无需再担心此限制,因为自 Gradle 2.1.0 版以来,增量选项默认为 true

-note: you dont need to worry about this limitations anymore because incremental option is true by default since Gradle version 2.1.0

multidex:此选项意味着将 java 代码编译成多个 dex 文件,除非您的代码方法超过单个 dex 文件的最大限制(64k 方法)

multidex: this option means compiling java code into multiple dex file you dont need this unless your code methods outnumbers the max limitation on a single dex file (64k methods)

jumboMode(第二个问题的答案):dex 文件中的字符串数量也有限制,启用此选项将扩展 dex 文件中的字符串数量(这个选项从 Gradle 2.1.0 开始就生效了,所以你也不必担心)

jumboMode (the answer of your second Q): there is also a limitation for strings count in the dex file enabling this option will extend the strings count in dex file (this option is true since Gradle 2.1.0 so you dont have to worry about it either)

preDexLibraries(你的第三个问题的答案):它从库中构建 dex 文件,因此它可以用于增量构建(不是每次都为库构建 dex 文件).所以在干净构建时使用这个项目会让一切都变慢.

preDexLibraries (the answer of your third Q): it builds dex file out of libraries so it can be used in incremental builds (not building dex files every time for libraries). so using this item when clean build makes everything a little slower.

这篇关于什么是增量,preDexLibraries,jumboMode,在 dexOptions 里面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆