You can different types of dependencies in a project:
dependencies {
// Dependency on the "mylibrary" module from this project
compile project(":mylibrary")
// Remote binary dependency
compile 'com.android.support:appcompat-v7:24.1.0'
// Local binary dependency
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Also you can use aar files defining a flatDir
:
repositories {
flatDir {
dirs 'libs'
}
}
then adding the dependency:
dependencies {
compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar')
}
To create a library module just create a module in Android Studio and use in the module/build.gradle
apply plugin: 'com.android.library'
Then you can use it as:
- a project (
compile project(":mylibrary")
)
- you can build the aar file and use it as aar file
- upload the library in a maven repository and use it as remote dependency