Jan-Lukas Else

Thoughts of an IT expert

Publish multi-module Android libraries on JitPack

Published on in 👨‍💻 Dev
Updated on
Short link: https://b.jlel.se/s/1eb
⚠️ This entry is already over one year old. It may no longer be up to date. Opinions may have changed.

If you’re an Android developer and learned to love the benefits of open source, you may want to publish you’re own libraries sometime. A common used services for building and providing Android libraries is JitPack. It’s a user friendly alternative to jCenter, which takes a lot of pain from the process of publishing a library. It’s as simple as adding a few lines of code to your project.

Now, given the case, that you already have an open source Android app, where you developed some special features (that may be helpful for other developers too), you don’t want the other developers needing to copy parts of your app. You want to give them a library, they can simple add as dependency to there build.gradle file.

All you have to do is moving these features to a separate module in your project by using the Android Studio built-in feature to create library modules. Now you need to specify these modules as dependencies for you app module, move the .java (or .kt for Kotlin) files over to the library module and fix things if needed.

After you have done this, simply add this to your root build.gradle file into the buildscript dependencies (after the Android gradle plugin reference):

classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'

And this to each library’s build file:

apply plugin: 'com.github.dcendents.android-maven'  

After this:

apply plugin: ‘com.android.library’

Of course you need to replace USERNAME and REPO with your Github username and the corresponding repository.

It’s almost done!

After your next push to Github and creating a new release, you’re modules will be available as separate libraries via:


Make sure, that you add JitPack as a Gradle repository (how to do this is described on their page)!

Tags: , ,

Jan-Lukas Else
Interactions & Comments