5

My Gradle build time is usually around 12 seconds, but after around 10 - 20 builds it starts to increase at once, exponentially: 30 seconds, 50 seconds, 2 minutes, 5 minutes, etc. up to out of memory.

Healthy build:

:app:compileDev21DebugJavaWithJavac 4.783s
:app:transformClassesWithRealmTransformerForDev21Debug  3.011s
:app:transformClassesWithDexForDev21Debug   2.133s
:app:compileRetrolambdaDev21Debug   1.325s
:app:packageDev21Debug  0.997s
:app:processDev21DebugResources 0.703s

After 10 - 20 of those, it starts increasing:

:app:transformClassesWithDexForDev21Debug   39.172s
:app:compileDev21DebugJavaWithJavac 34.221s
:app:packageDev21Debug  9.922s
:app:transformClassesWithRealmTransformerForDev21Debug  8.353s
:app:compileRetrolambdaDev21Debug   3.120s
:app:fabricGenerateResourcesDev21Debug  1.376s

As you can see, every task increases in time.

I use Android Studio 2.2.2, but I had the problem since the last 3 versions or so. Gradle 2.14.1. Probably it’s related to our project. I use Mac, my colleague on Windows has the same on the same project. If I stop AS, kill Java and start AS again, that solves it for a while.

I am not using the Jack compiler (yet).

To be clear: my build time is NOT generally slow: 13 seconds is fine. This is not a duplicate of all the "slow build time" questions. Only after 10 - 20 builds the build time increases exponentially with every build.

Update: Make Gradle build "offline" didn't help. Using "gradle-3.1-all.zip" (distributionUrl in grade-wrapper.properties) also did not help.

Anyone had this problem and knows a solution?

Frank
  • 12,010
  • 8
  • 61
  • 78
  • There are huge building time issues with Android Studio v2.+ – Murat Karagöz Oct 31 '16 at 14:03
  • 1
    @MuratK. where did you read that? – Blackbelt Oct 31 '16 at 14:04
  • Possible duplicate of [Android studio Gradle build speed up](http://stackoverflow.com/questions/17324849/android-studio-gradle-build-speed-up) – OneCricketeer Oct 31 '16 at 14:05
  • @Blackbelt My own experience and literally ever question about this particular issue that is popping up since the official release of the jack compiler. – Murat Karagöz Oct 31 '16 at 14:05
  • Personally, I use Intellij IDEA. Haven't switched to jack compiler, though – OneCricketeer Oct 31 '16 at 14:06
  • 1
    @cricket_007 You can test is by enabling jackOptions and setting compileOptions to Java 1.8. Build times will shoot through the roof. – Murat Karagöz Oct 31 '16 at 14:07
  • check [this bug report](https://code.google.com/p/android/issues/detail?id=203168), Frank. Especially last comment. If you are really using jack – Blackbelt Oct 31 '16 at 14:09
  • I have set 1.8... Just curious. Running `gradlew`, does the problem persist? Then the problem isn't the IDE. There's claims that Gradle 3.1 has good speed ups, though not sure if AS works with it – OneCricketeer Oct 31 '16 at 14:10
  • 1
    I edited my question: I am not using the Jack compiler (yet). This is not a duplicate: build times are generally fine but increase after 10 - 20 builds. I will try gradlew. – Frank Oct 31 '16 at 14:16
  • 1
    @cricket_007 pls read the question, this is not a duplicate. That post you linked to is ancient and relates to the general slowness of gradle especially back in those days. This is about a normally fast build that gets slower after some hours of work. – Richard Le Mesurier Oct 31 '16 at 15:15
  • 1
    1 - are you using the gradle wrapper in android studio? 2 - Does this occur after 10-20 `gradle(w) assemble` too? or just in AS? (plz edit question with answers) – petey Oct 31 '16 at 15:47

2 Answers2

1

I experienced(and somehow still facing) the same issue. There are some fixes that you can try.

1- Make Gradle build Offline.

2- Install Gradle on machine and use local installation alongside Offline work checked in Android Studio instead of Using wrapper which connects to proxy and takes more time with building cache of Studio.

I followed this and this article and it helped me not substantially but enough to get me nearly 6,7 hours of continuous development on 8GB memory system then i have to Invalidate and Restart.

mfaisalhyder
  • 2,250
  • 3
  • 28
  • 38
  • Make Gradle build "offline" didn't help. Using "gradle-3.1-all.zip" (distributionUrl in grade-wrapper.properties) also did not help. I'll try number 2 now. – Frank Nov 01 '16 at 07:09
-1

It is fixed since the day that I removed Fabric (CrashLytics) and replaced it with FireBase Crashes. Fabric was most probably causing it, but I'm not 100% sure.

Frank
  • 12,010
  • 8
  • 61
  • 78