40

I'm currently using ant to build Android projects but it simply doesn't cut it for larger projects and maintaining different deliverables is becoming a pain.

Two alternatives I'm looking at are Facebook's Buck (http://facebook.github.io/buck/) and Gradle that Google is backing with Android studio (http://tools.android.com/tech-docs/new-build-system/user-guide).

Besides trying them out and reading up on their coverage I would like to ask you fine Stackoverflow people for your recommendations. Preferably if you've used either tool for a while, with bonus points for Buck since it didn't get that much coverage.

Important points are

  • build speed, specifically for dev builds
  • multiple deliverables from same code base
  • ease of use

I'm open to other alternatives as well. What do you suggest and why?

Martin Konicek
  • 39,126
  • 20
  • 90
  • 98
Geert Weening
  • 1,480
  • 1
  • 13
  • 17
  • i like gradle (don't know buck). gradle is a bit slow, but you can speed things up with the gradle daemon (http://www.gradle.org/docs/current/userguide/gradle_daemon.html) – Ray Tayek May 22 '13 at 00:22

4 Answers4

44

As I put front and center in the Buck documentation: "Buck is a build system for Android that encourages the creation of small, reusable modules consisting of code and resources."

By design, Buck encourages you to create small modules so that you can easily compose a new app out of your existing building blocks. This means that maintaining multiple deliverables is straightforward: it eliminates boilerplate without requiring you to organize your repository into a predefined structure. You can also create ad-hoc build steps to suit your needs with Buck via macros and genrules. (A more formalized extension system is in the works.)

We also care a lot about speed, particularly the speed of incremental builds. Because Buck has a strong concept of dependencies, we can often avoid rebuilding intermediate artifacts. Other build systems also try to do this (like Ant), but frequently sacrifice correctness, as a result. We don't.

We recognize that IDE support is important. Certainly Google's collaboration with Gradle gives them a leg up there. However, Buck has a command to generate an IntelliJ project from the dependency graph defined in Buck build files, and we have broken ground on our own IntelliJ plugin, so this is something that we also care deeply about.

Finally, bear in mind that Buck is used to build Facebook, Facebook Messenger, and Instagram for Android. Buck is not going away. Further, the code for all three apps (and reduced versions of the apps, for even faster development cycles) lives in one Git repository at Facebook, so those of us working on Buck internally are sensitive to the needs of large codebases that support multiple deliverables.

bolinfest
  • 3,710
  • 2
  • 27
  • 40
  • 1
    Note that Buck still does not seem to have dependency management in the sense that JARs / AARs can be dynamically retrieved from Maven Central / JCenter and cached locally for use with the build. I believe [the Gerrit folks have some simple custom code](https://groups.google.com/d/msg/repo-discuss/Ab4y-D8lcWI/f2YLOPICFr8J) that at least downloads JARs, but does not cache them. – sschuberth Apr 15 '15 at 10:46
  • 2
    Buck has the [fetch command](https://buckbuild.com/command/fetch.html) that can do this, @sschuberth – sdwilsh Nov 03 '15 at 22:12
  • @bolinfest Now that Google is pushing modularising the app for better build times as parallel build for these modules can be enabled. Also this would be basic required for dynamic feature delivery, does Buck still add values in some way that it should be preferred over Gradle? – Arpit Ratan Jan 20 '20 at 17:47
8

Long-term, the new Gradle build system will be the standard, and it looks very good. However, it looks like it's not quite ready for use in non-trival projects yet. For instance, it looks like it doesn't support apklib dependencies yet.

This is understandable, and reflected in the fact that the current version is 0.3 I'm looking forward to seeing it evolve.

For a project that needs to be build today, I'd use Maven. Actually, I'm in the process of moving a client's build from Eclipse-only to Maven right now, so that they can have a repeatable build process, good dependency management, and CI. The new Gradle build looks like it will be more flexible, but right now Maven handles apklibs. Since Gradle can use Maven dependencies, I'm expecting that we'll be able to move from Maven to Gradle easily in the future.

I don't know anything about Buck. However, that in itself is a red flag. I'd hesitate to use a build system that few people know anything about. That doesn't mean that it's not good - it may be great. But using it now is probably a gamble.

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
  • How did you find the build speed of debug builds under Gradle? Ant is pretty slow and I know Buck is a lot faster. Since you used Gradle how would you say the speed is for building debug builds while developing – Geert Weening May 22 '13 at 18:25
  • I haven't actually used Gradle, just Maven. I'm using IntelliJ, and can use the IDE's build (which is pretty fast) during the normal development / test cycle, and still use the Maven build (which is slower) for final testing, CI, and releases. – GreyBeardedGeek May 23 '13 at 03:33
7

Here is a gradle plugin OkBuck which can let you start using BUCK base on your current Android Studio + Gradle build system with only 10 lines of configuration. Check it out.

OkBuck can let you build your project both with gradle and buck, with all advantages of gradle and buck.

Piasy
  • 989
  • 13
  • 35
5

I would add the following advantages of Buck:

  • Exopackage, i.e. incremental apk build; just check the table with build time on that page
  • Network cache. If you have several developers working with an app, you won't need to rebuild components which are already built by other developers.
tcb
  • 2,745
  • 21
  • 20
  • 1
    Vine also saw some nice wins because of exopackage: http://engineering.vine.co/post/117873038742/reducing-build-times-by-adopting-buck – sdwilsh May 26 '15 at 22:44