gradle - Android Studio build too slow multidex application

后端 未结 4 1087
悲&欢浪女
悲&欢浪女 2020-12-09 16:12

When I add to my project the multidex:true, and make an Application class that extends from the MultiDexApplication, my project build time passed from 20 sec to around 90 se

4条回答
  •  攒了一身酷
    2020-12-09 16:40

    Multidexing uses more memory. As you get closer to your max heap size in Java you'll find Java spends more time doing GC than it does doing any real work, this can slow things down a lot.

    I'd strongly recommend increasing the max heap size when using multidex. Add the following to the android closure in your build.gradle file to make the max heap size 4GB (Make it larger/smaller if you wish):

    dexOptions {
        javaMaxHeapSize "4g"
    }
    

提交回复
热议问题