Requesting Plugins

The first lines in app/build.gradle usually request various plugins. The lines that you added to the top-level build.gradle file specify sources of plugins, but those libraries can have many different plugins, and you only need some of them. Plus, if your project grows and you have more modules than just app, you might need a different mix of plugins per module.

As a result, each module’s build.gradle file starts off with a plugin closure to indicate what plugins are needed:

plugins {
  id 'com.android.application'
  id 'kotlin-android'
}

Both the Java and the Kotlin editions of the starter project will request the com.android.application plugin. This teaches Gradle how to build Android apps. There are other options here, such as com.android.library to teach Gradle how to build an Android library, but nearly every project will have at least one module using com.android.application.

Kotlin-based projects will also request the kotlin-android plugin. This teaches Gradle how to compile Kotlin code, particularly in the context of building an Android application.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.