Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle build incredibly slow

Build time right now is ranging around ~2-4 min.

I'm using about 11 libraries provided via Gradle.

I have the following set:

buildTypes {
    debug {
        multiDexEnabled = true
        applicationIdSuffix ".debug"
        minifyEnabled false
        proguardFile 'proguard-rules.pro'
    }
}

dexOptions {
    javaMaxHeapSize "4096M"
    preDexLibraries false
    jumboMode = true
    incremental = true
}

Gradle: Offline mode

I have the following setting in gradle.properties org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

In the global properties I have:

org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true

I've looked through about every article I can find on it on Google/Stackoverflow.

Is there any way to speed the process up to below 1 minute at least?

Update August 6, 2015

These really helped speed things up for me.

gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip

build.gradle project dependencies

classpath 'com.android.tools.build:gradle:1.3.0'

Update August 9, 2015

I've found that as it turns out using Protoc is very very slow for Android. I switched to Wire and it took the compilation time from 2 min. to 10s-30s.

like image 468
Sherlock Avatar asked Jun 02 '15 21:06

Sherlock


2 Answers

I found that multiDexEnabled = true makes my build process extremely slow. I don't know if it's possible to improve it's performance somehow, but for now I just turned it off.

You have to use it only if amount of methods in your project (including libraries) goes beyond 65k limit. Maybe you can cut off some of your 11 libraries, then turning off multiDexEnabled option should solve your problem.

like image 153
Ayzen Avatar answered Sep 22 '22 07:09

Ayzen


You can also upgrade gradle by editing the gradle-wrapper.properties file and set gradle-2.4-all.zip

distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
like image 20
sonique Avatar answered Sep 23 '22 07:09

sonique