Appendix B. Gradle: The Gradle Build Tool

Most Android apps are created using a build tool called Gradle. Gradle works behind the scenes to find and download libraries, compile and deploy your code, run tests, clean the grouting, and so on. Most of the time you might not even realize it’s there because Android Studio provides a graphical interface to it. Sometimes, however, it’s helpful to dive into Gradle and hack it manually. In this appendix we’ll introduce you to some of Gradle’s many talents.

What has Gradle have the Romans ever done for us?

When you click the run button in Android Studio, most of the actual work is done by an external build tool called Gradle. Here are some of the things that Gradle does:

  • Locates and downloads the correct versions of any third-party libraries you need.

  • Calls the correct build tools in the correct sequence to turn all of your source code and resources into a deployable app.

  • Installs and runs your app on an Android device.

  • A whole bunch of other stuff, like running tests and checking the quality of your code.

It’s hard to list all of the things that Gradle does because it’s designed to be easily extensible. Unlike other XML-based build tools like Maven or Ant, Gradle is written in a procedural language (Groovy), which is used for both configuring a build and adding extra functionality.

Your project’s Gradle files

Every time you create a new project, Android ...

Get Head First Android Development, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.