Add local Library Project as a dependency to multiple Projects in Android Studio

You can also refer to a library outside of your project folder using the project().projectDir property. If your external library is relative to your project like so

- MyLibrary
   - library
- MyProject
    - app

in MyProject/settings.gradle

include ':library'
project(':library').projectDir = new File(settingsDir, '../MyLibrary/library')

in MyProject/app/build.gradle

dependencies {
   compile project(':library')
}

This is very similar to this question:

Sharing an Android library between multiple Android apps using Gradle

Instead of pushing to maven central you can push to your local maven repository (mavenLocal() in build.gradle)


Another route (if you don't want to deploy the library somewhere) is to use your VCS and check out the library within your project. Git has submodules for that, Mercurial has subrepos and SVN has external to name a few examples. Then add it to your Gradle build using a project dependency.