I am new on Android development and my Gradle build process tooks long time. Its annoying for me to wait for gradle build. Any Help is appriciated. Thanks in advance
-
Maybe the answers to this question help you: http://stackoverflow.com/questions/17324849/android-studio-gradle-build-speed-up?rq=1 – l7r7 Sep 10 '16 at 17:49
-
what AS version are you using? – Kosh Sep 10 '16 at 17:51
-
This link works https://hackernoon.com/speed-up-gradle-build-in-android-studio-80a5f74ac9ed – Atul Bhardwaj Jul 26 '17 at 09:58
3 Answers
There are some solutions I have mentioned:
Technique #1
Open up gradle.properties file
add the following line
org.gradle.daemon=true
Technique #2
Open up gradle.properties file
add the following line
org.gradle.parallel=true
Technique #3
Open up gradle.properties file
add the following line
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Technique #4
There are many other techniques for optimizing the speed of gradle build. If you are still having the problem I prefer you to use gradle from command line.
For more details, you can see a discussion on G+ with the developers about it.

- 1,397
- 1
- 13
- 34
-
-
For #3 make sure you analyze how much memory you have for your system. If you have 2g of memory only that will not be efficient for your system. – Ray Hunter Sep 10 '16 at 18:00
-
Yeah, 2 GB RAM is minimum requirement for Android Studio and 8 GB is recommended :). Less than 8GB will definitely run slower – Ngima Sherpa Sep 10 '16 at 18:07
-
I would suggest running all 3 of the techniques along with some android gradle plugin dexOptions too:
I have the following my gradle.properties file:
org.gradle.daemon=true
org.gradle.jvmargs=-Djava.awt.headless=true -Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
I also have dexOptions in the app/build.gradle file too:
dexOptions {
incremental true
javaMaxHeapSize "4096M"
jumboMode true
maxProcessCount 8
preDexLibraries false
threadCount 8
}
You can tune those values for you system. Here is more information about those options:
dexInProcess - Whether to run the dx compiler as a separate process or inside the Gradle daemon JVM.
javaMaxHeapSize - Specifies the -Xmx value when calling dx. Example value is "2048m".
jumboMode - Enable jumbo mode in dx (--force-jumbo).
maxProcessCount - The maximum number of concurrent processes that can be used to dex. Defaults to 4.
preDexLibraries - Whether to pre-dex libraries. This can improve incremental builds, but clean builds may be slower.
threadCount - Number of threads to use when running dx. Defaults to 4.

- 15,137
- 5
- 53
- 51
I just accidentally found how to build 2 times faster. May be it will be fix in the future, but now it works like clockwork. All you need to is hide your studio (cmd + H or cmd + R for mac, win + D for Windows). I tested it with more then 100 builds for now (Android Studio 2.3), there were no exceptions.

- 1,252
- 14
- 17