Slow Android multi-project builds

Gradle builds really slow with a multi-project structure.

I currently have this question asked at http://stackoverflow.com/q/21125302/427763.

When building with gradle on a multi-project setup containing roughly 140 projects/libraries, the build time took 1 hour and 22 minutes. And i was using --parallel. And our ANT build takes less than 20 minutes without parallel building.

Here is exactly what i did.

./gradlew clean ./gradlew build --parallel

I did a little testing it seems like the dexing is taking the longest amount of time. Is there a way to get the gradle process to re-use the stuff it has already dexed? If the libraries have already been built, it should re-use the already dexed libraries.

I saw the option --no-rebuild, but when i run with that option it says the following

File ‘/path/to/project/build/libs/project.aar’ specified for property ‘bundle’ does not exist.

I replaced the file path and project name with generic stuff.

Using Gradle 1.9-rc-3

After some more testing and answers from other people i have the build time down to 52 minutes. Which is still very unreasonable.

I added “preDexLibraries = false” to all the build.gradle files and i ran the following command:

./gradlew assembleDebug

This made it only do the debug. It seems as though it is not re-using the dexed files that it builds. Is there a way to further improve the build time? How can we get gradle to re-use those dexed libraries? It takes 1+ minute to dex each project.

Thanks

Why do you run ‘clean’ between builds? This forces Gradle to rebuild everything, without reusing previous build results.

I am only running clean at the beginning before I start the full process. Not between each project build. And I am running a clean build for the build speed testing because that is our bench mark. Right now ant will complete the same build in about 12 minutes from clean. Gradle is taking an hour from clean. The ant build process we are using is the standard ant build process from android, modified quite a bit to work with a lot of projects. We need the build time down to about the same, before we can move onto gradle. And the biggest thing with gradle is the dexing is taking 1+minute for each project. So it seems like it is not reusing the libraries it has already dexed. Is there a way to further speed this process up?

I’m not sure. Perhaps ask the authors of the plugin.

Well, this is the gradle help forum. Is this not the place? Where would I go for gradle official help?

It’s fine to post here, but the Android plugin is developed by Google, so that’s where you’ll find the experts on this particular plugin. http://tools.android.com/feedback might be a good start.

Thanks, posted the question there.