If you are using Android Studio, then you’ve seen Gradle in action. Yep, Gradle is the engine behind the build system used in Android Studio, which is, together with Google’s Android plugin for Gradle, responsible for building your Android application and producing the final .apk files.
Gradle is a powerful build tool, written in a simple script language called Groovy. It takes care of a lot of the plumbing related to building an application – resolving dependencies, downloading artifacts from repositories and determining which tasks need to run in order to build your app. Gradle then runs the tasks that compile, merge, handle resources etc until your app is ready. Gradle is also simple to configure. Typically, with a few declaration lines in your build.gradle you are ready to go.
But this is exactly what makes Gradle somewhat complex to understand, because a lot of the work is done under the hood, typically by plugins, some built-in (like the java plugin), and some being 3rd party plugins, like the Android plugin and the SafeDK plugin. If you are someone like me that likes understanding what’s going on behind the scenes – it’s not always that easy.
There’s of course a lot to tell about Gradle and the Android build system. So much, in fact, that this is just the first out of a two-part story (part 2 coming next week). In these couple of posts I’ll focus on a specific topic – I’ll try to guide you through setting up an environment where you can compile an Android application using Gradle, but without the Android Studio IDE. Why would you want to do that? Well, it has to do with buzzwords like “build server”, “continuous integration” etc. While you can build and deploy your app in Android Studio, if you have multiple people working on the app, you may want a central build server with a consistent environment, where you continuously integrate, run automated tests, produce versions for your QA team and produce the final versions. This is btw one of the nice things in Android Studio – the fact that you can completely decouple the build system from the graphical IDE.
Here I’ll go over some terms and mechanisms which are essential for part 2, where I’ll detail the steps to set up your independent build server.
OK, so let’s dive in.