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

Adding modules to a project


Adding a new module is as simple as going through a wizard in Android Studio. The wizard also sets up the basics of the build file. In some cases, adding a module will even cause Android Studio to edit the build file of your app module. For example, when adding an Android Wear module, the IDE assumes that you want to use it for your Android app, and add a line in the build file to reference the Android Wear module.

This is what the New Module dialog in Android Studio looks like:

In the following sections, we will show different modules that can be added to an Android project with Android Studio, explain their custom properties, and specify how they alter the build process.

Adding a Java library

When you add a new Java library module, the build.gradle file generated by Android Studio looks like this:

apply plugin: 'java'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

Java library modules use the Java plugin instead of the Android plugins we are...