All Articles

Gradle module-to-module dependencies

Sometimes I need to make a small change to a 3rd party library and add it as a dependency to my Android Studio project manually. Things immediately gets a little more complex than the usual compile 'foo-bar-lib:1.2.3' - you could easily paste the whole lib into your src/main/java/ hierarchy, but that’ll make your brain hurt each time you see it.

Instead we can use module dependencies to get a structure looking like:

.
├── app
│   ├── build.gradle
│   └── src
│
├── libs
│   ├── android-timetable-core
│   │   ├── build.gradle
│   │   └── src
│   └── /*... more libs*/
│
└── build.gradle

Where the app/build.gradle includes android-timetable-core like compile project(':libs:android-timetable-core').

Use module dependencies

I made a repo demonstrating how to get the 3rd party lib added as a dependency module for future reference (and as a helpful answer on the android-dev Discord channel).

Github: paramsen/torch-android-build-box

Code hard!

Published 11 May 2017