Gradle build incredibly slow

Build time now is about ~ 2-4 minutes.

I use about 11 libraries provided through 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 global properties, I:

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

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

Is there a way to speed up the process to less than 1 minute?

August 6, 2015 Patch

It really helped speed up the process 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' 

August 9, 2015 Patch

I found that using Protoc for Android turned out to be very slow. I switched to Wire and it took a compilation time of 2 minutes. up to 10 s-30 s.

+8
performance android gradle
source share
3 answers

I found that multiDexEnabled = true makes my build process very slow. I do not know if it is possible to somehow improve its performance, but so far I just turned it off.

You should use it only if the number of methods in your project (including libraries) goes beyond 65k. Perhaps you can turn off some of your 11 libraries and then turn off the multiDexEnabled parameter to solve your problem.

+1
source share

You can also update 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 
+1
source share

You need to enable gradle daemon .

Create a file called gradle.properties in the following directory:

  • / home //. gradle / (Linux)
  • / Users //. gradle / (Mac)
  • C: \ Users \ .gradle (Windows)

Add this line to the file:

 org.gradle.daemon=true 

Now Gradle will use the daemon to build using Gradle from the command line or building in Android Studio.

0
source share

All Articles