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?
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!
will take 10-12 mins after that it will be good to go.
Recently I enabled multidex in my app because I had over 65k methods. Dexing is what was taking a lot of time to complete.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With