Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does assembleDebug takes much longer then project build and how to optimize it?

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?

like image 667
Oleg Filimonov Avatar asked Jan 15 '16 12:01

Oleg Filimonov


People also ask

How do I speed up gradle task assembleDebug?

Enable build caching For example, ./gradlew assembleDebug --build-cache . You can also configure build caching on your gradle. properties file. Estimates that this will improve your full clean build by up to 3 times faster, and incremental builds by up to 10 times faster!

How long does gradle assembleDebug take?

will take 10-12 mins after that it will be good to go.


1 Answers

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

like image 184
Oleg Filimonov Avatar answered Sep 21 '22 09:09

Oleg Filimonov