The build time for Gradle My Gradle is usually about 12 seconds, but after creating about 10-20 units, it starts to increase immediately, exponentially: 30 seconds, 50 seconds, 2 minutes, 5 minutes, etc. before exiting the 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 to 20 of them, it begins to increase:
: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, each task increases in time.
I am using Android Studio 2.2.2, but I have had a problem with the last three versions. Gradle 2.14.1. This is probably due to our project. I am using a Mac, my Windows colleague has the same in the same project. If I stop AS, kill Java and run AS again, which solves it for a while.
I do not use 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 "slow build time" questions. Only after 10-20 builds does the assembly time increase exponentially with each assembly.
Update: make Gradle build "offline" did not help. Using gradle -3.1-all.zip "(distributionUrl in grade-wrapper.properties) didn't help either.
Has anyone had this problem and knows the solution?