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, ...

Get Gradle 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.