Extremely long build with Gradle (Android Studio)

前端 未结 5 638
天涯浪人
天涯浪人 2020-11-29 21:17

right now we are in a situation of having build times 2 minutes 30 seconds for very simple change. This (compared to ANT) is amazingly slow and is killing the productivity o

5条回答
  •  囚心锁ツ
    2020-11-29 21:48

    I'm not quite sure why Android Studio is slower than the command line, but you can speed up your builds by turning on incremental dexing. In your module's build file, add this option to your android block:

    dexOptions {
        incremental true
    }
    

    In that dexOptions block you can also specify the heap size for the dex process, for example:

    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
    }
    

    These options are taken from a thread on the adt-dev mailing list (https://groups.google.com/forum/#!topic/adt-dev/r4p-sBLl7DQ) which has a little more context.

提交回复
热议问题