Ondřej Z
Ondřej Z

Reputation: 5174

Building android project takes too long in Eclipse

I have a relatively small project (50 classes) that has included 13 JAR libraries (android-support, gson, guava etc) and uses one Android library (Sherlock).

The problem is that whenever I press "Build Project" it takes around two minutes to build/deploy to a device. (However newly created android project takes no more than 5 seconds to build).

Is there something I can do with it (limit number of libs, switch to another IDE)? Or it is just usual behavior.

Upvotes: 0

Views: 1415

Answers (3)

Simon
Simon

Reputation: 14472

AlexR has a good answer. To add:

I use IDEA so I don't know how to do this in Eclipse but I know it can be done - probably right click context menu.

Exclude any layouts that you don't really need for dev/test from your build. I tend to put placeholder layouts in early in a project then refine them later in the project when the main code is getting to alpha quality. I exclude everything except one set, e,g. "normal" portrait, do all of my code creation then only add the layouts back in near the end.

Same goes for assets. Do you have a lot of assets or assets of large size? Exclude these, or perhaps temporarily replace with smaller ones.

All this said, the compilers used do a very good job of optimisation and as the number of classes grows, it is inevitable that your build time will increase. It's not exponential (I've never actually measured it) but it's certainly worse than linear.

Upvotes: 1

Leon Lucardie
Leon Lucardie

Reputation: 9730

The project takes that long to compile because it needs to add the JAR files and Sherlock library. Every library added to the project will increase the build time of the project.

Switching to another IDE would not make a huge difference because a lot of the building is handled by the Android SDK.

Your best bet would probably be to limit the libraries of your project using elimination to see which causes the largest build time increase.

Upvotes: 1

AlexR
AlexR

Reputation: 115328

I do not have direct answer to your question but I can recommend you the following steps.

  1. You compare build+deploy of "Big" project with build of "Small" project. Did you try to compare exactly same operation for both? What the result is?
  2. Try to create new workspace. Sometimes it helps to Eclipse.
  3. Try to take "Small" project and move from it to "Big" one step-by step. For example add dependencies first. Try to build the project. The time did not significantly changed? Go forward and add 20 custom classes etc. The time changed? Try to find which library causes this. You can also choose other strategy: try to add classes without adding dependent jars, just comment out code that uses dependencies. This way may be more complicated but I believe still possible since your project is indeed to too big.

Good luck.

Upvotes: 0

Related Questions