Reputation: 20637
Is it normal that building Gradle of my android project takes at least 8 minutes and something goes up to 20 minutes?
I am running on Windows 10 with 8 Gb RAM, 1.7 Ghz Intel core i3 processor.
If not, kindly advice how to speed up the building time.
Upvotes: 2
Views: 2603
Reputation: 2181
Delete the files in build/android-profile
(It contains .rawproto and .json files)
After doing this you may see monstrous speed increases. One of the reasons for the slowdown may be Lint checking these files during the build. The folder had grown to 2GB on my computer and contained over 7000 files. That can't be good. I guess an alternative approach could be to configure Lint to ignore this folder, but I haven't investigated any further.
Warning: I am not completely sure whether these files have any value, so you can check for yourself. You definitely don't need them in order to build the project, that's for sure (you don't check them in GIT anyway).
Upvotes: 1
Reputation: 216
You can add following code in gradle.properties . this file will be under your project folder.
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
And add following code in you app build.gradle file
lintOptions {
disable 'InvalidPackage'
}
dexOptions {
incremental true
maxProcessCount 4
javaMaxHeapSize "4g"
}
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
task.enabled = false
}
Upvotes: 1
Reputation:
Following the steps will make it 10 times faster and reduce build time 90%
First create a file named gradle.properties in the following directory:
/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)
Add this line to the file:
org.gradle.daemon=true
org.gradle.parallel=true
Upvotes: 4