12

I've been dealing with gradle build time in Android Studio recently. I've managed to decrease the build time from about 3 mins to 10 seconds by removing some dependencies, but here's the thing:

When I rebuild project it takes about 10 seconds:

15:13:43 Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources]
15:13:54 Gradle build finished in 11s 596ms

However when I launch the app, it takes a lot longer, about a minute:

15:15:09 Executing tasks: [:app:assembleDebug]
15:15:58 Gradle build finished in 49s 676ms

What is the cause of such big difference? Is this still because of the large amount of gradle dependencies or something else? Can I reduce the build time somehow?

KKishore
  • 452
  • 5
  • 12
Oleg Filimonov
  • 1,323
  • 4
  • 13
  • 36

1 Answers1

22

Why:

Recently I enabled multidex in my app because I had over 65k methods. Dexing is what was taking a lot of time to complete.

How to speed up build:

Go to Settings (Ctrl + alt + s) -> Build, Execution, Deployment -> Compiler

Enabling compiling modules in parallel and adding --offline in compiler has decreased my execution time to about 15 seconds.

enter image description here

MendelG
  • 14,885
  • 4
  • 25
  • 52
Oleg Filimonov
  • 1,323
  • 4
  • 13
  • 36