1

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.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
TSR
  • 17,242
  • 27
  • 93
  • 197
  • 2
    that is really long but to "speed up" the time, we need to where the problem lies. Show your gradle configuration. Also make sure that in your `gradle.properties` file, there are no proxy settings – ᴛʜᴇᴘᴀᴛᴇʟ Oct 02 '16 at 04:20

3 Answers3

3

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
1
    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
        }
Anantha Babu
  • 216
  • 2
  • 14
1

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).

Stan
  • 2,151
  • 1
  • 25
  • 33