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')
}

Leave a Comment