Foreword

This is the book we needed. We were about halfway through writing Head First Android Development when Google switched IDEs. At the time, pretty much everyone was using Eclipse with the Android Development Toolkit installed. But now, Google was pushing for developers to switch to the Idea-based Android Studio.

We’re used to this kind of thing—most technical authors are. Some manufacturer startup switches from some new shiny thing to some even newer, even shinier thing. It happens all the time. You rewrite all your example code, update all the images, drop the features that are now irrelevant, and include what’s most useful from the new technology. But what made the switch from Eclipse to Android Studio different was that under the hood the new IDE had a much, much more powerful engine.

Android Studio used Gradle for building, packaging, and deploying code. Other than knowing the name, neither of us had any experience of using Gradle directly. It was kind of like Maven, but rather than using lengthy XML configuration files, it used a sturdy and concise scripting language: Groovy.

We replaced all the screenshots, and updated the text in the seven or so chapters that were already written and then moved on to write the rest of the book. But it soon became clear that the process of creating applications with Gradle was subtly, but significantly different. Pretty much anything that you could do from the IDE was suddenly possible from the command line, which meant we could automate our build pipelines. It took just a few key presses to try out different library versions, or different build flavors. And because everything is just code, we could write the builds in the same way that we wrote the rest of the app.

Learning Gradle is now an important task for every Android developer. It’s up there with knowing Java, or understanding the Activity lifecycle. But learning Gradle through trial-and-error can sometimes be a painful process. And that’s where this book comes in. In these pages, you’ll find a wealth of useful recipes that will help you avoid the commonest build problems. Whether you’re setting up a testing system, automating your signed APK production, or just trying to speed up your build pipeline, this book is for you. Ken’s lively writing style and realistic examples will keep you coming back again and again. With this book, Ken has shown that not only is he the go-to guy for Groovy, he’s now also the go-to guy for Gradle.

Get Gradle Recipes for Android 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.