Book Image

Gradle for Android

By : Kevin Pelgrims
Book Image

Gradle for Android

By: Kevin Pelgrims

Overview of this book

Table of Contents (16 chapters)
Gradle for Android
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding the Gradle files


When creating a new project with Android Studio, three Gradle files are generated by default. Two of those files, settings.gradle and build.gradle, end up on the top level of the project. Another build.gradle file is created in the Android app module. This is how the Gradle files are placed in the project:

MyApp
├── build.gradle
├── settings.gradle
└── app
    └── build.gradle

These three files each serve their own purpose, which we will further look into in the upcoming sections.

The settings file

For a new project containing only an Android app, settings.gradle looks like this:

include ':app'

The settings file is executed during the initialization phase, and defines which modules should be included in the build. In this example, the app module is included. Single module projects do not necessarily require a settings file, but multimodule projects do; otherwise, Gradle does not know which modules to include.

Behind the scenes, Gradle creates a Settings object for...