Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optimizing build time in Android Studio

I've tried building it:

  • parallel (helps a bit)
  • daemon=true
  • preDexLibraries true/false ( no big difference )
  • incremental true
  • offline

It takes >40s EVERY time. It doesn't matter if I change anything or not. Building it after "gradle clean" takes >50s.

I hope that I'm doing something wrong. Eclipse/ant could build consecutive builds WITH CHANGES in <10s.

Any help how to bring this <10s appreciated. Yes, we have a lot of modules, some jar libraries, some maven dependancies. Still don't get why would it take >40s for two consecutive builds with no changes.

Gradle used: 2.2.1 Android studio: not really relevant, usually building it only with Gradle.

EDIT: adding some profiling logs.

:app:dexProjDebug 22.541s

:app:shrinkProjDebugMultiDexComponents 4.279s

:app:compileProjDebugJava 3.478s

:app:packageProjDebug 2.591s

:app:processProjDebugResources 2.590s

:app:packageAllProjDebugClassesForMultiDex 2.536s

:app:createProjDebugMainDexClassList 2.126s

like image 400
Danail Avatar asked Apr 09 '15 01:04

Danail


People also ask

What is build optimization?

Building optimization is the process of collecting credible data on a building's performance and longevity. This data could be about a planned construction or an existing building.


1 Answers

You need to properly define inputs and outputs even for library projects with source code. (Gradle Documentation). Do you get UP-TO-DATE message when you rebuild second time onwards?

like image 132
Bhisham Balani Avatar answered Sep 22 '22 09:09

Bhisham Balani