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

Local dependencies


In some cases, you might still need to manually download a JAR file or a native library. Perhaps you want to create your own library that you can reuse in several projects, without publishing it to a public or private repository. In those cases, it is impossible to use any of the online resources, and you will have to use different ways to add the dependencies. We will describe how to use file dependencies, how to include native libraries, and how you can include library projects in your project.

File dependencies

To add a JAR file as a dependency, you can use the files method that Gradle provides. This is what it looks like:

dependencies {
    compile files('libs/domoarigato.jar')
}

This can get tedious if you have a lot of JAR files, so it might be easier to add an entire folder at once:

dependencies {
    compile fileTree('libs')
}

By default, a newly created Android project will have a libs folder, and declare it to be used for dependencies. Instead of simply depending on...