painless publishing of android libraries

Libraries are only good when it’s easy to share them. Android has done this wrong for a very long time.

Node.js has npm and a new library can be published in a couple of minutes, usage is as simple as adding library name to package.json.

Go has no package manager at all and publishing a library is as simple as “git push” and using is as simple as “import”.

Android… Before Gradle it was a real disaster. Gradle finally made it possible to add libraries with just one line of code. But publishing your new library was still a problem.

maven central

Obviously, in Java world libraries are managed with Maven. When I published my first android library I’ve chosen Maven Central and described the steps I’ve taken.

It was a cumbersome process which required writing some code, creating an account on their website and waiting for a few days to make my registration complete.

That’s why when I heard about jCenter I decided to migrate.


Actually, I decided to migrate when I’ve read that Android Studio migrates to jcenter.

So I’ve made a Bintray account, added some gradle plugins to my libraries, wrote another few lines of gradle configuration and published my library. The process is well documented but look at the amount of code to be written!

And as a result you still have to link your library with jCenter and wait until they confirm your request.


Finally, I’ve heard about

Finally, no registration needed. You only need to have a repository on github or bitbucket.

Finally, no need to wait for any kind of confirmation before you can publish your new library.

Finally, publishing is as simple as git push and using is as simple as writing your library name in build.gradle.


First, create a new project on github. Assuming it’s an android library it can follow the structure of this repo:

Basically, all you need to change is to add android maven plugin to your library/build.gradle:

buildscript {
	dependencies {
		classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'

apply plugin: ''
apply plugin: ''

You might also want to add this to generate javadocs and sources JAR:

task sourcesJar(type: Jar) {
    classifier = 'sources'

task javadoc(type: Javadoc) {
    failOnError  false
    source =
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir

artifacts {
    archives sourcesJar
    archives javadocJar

Next, assign a release tag and push your code:

git tag 1.0
git push
git push --tags

Publishing is done. You may now use your library in other projects:

repositories {
	maven { url = '' }
dependencies {
	// for with tag 1.0:
	compile 'com.github.user:library:1.0'

And yes, that is it.

If you don’t have an assigned tag yet - you may use com.github.user:library:-SNAPSHOT and will always get the “tip” of the master branch.

Official documentation for JitPack publishing of Android libraries: here:

Official example of an Android library:

Issue tracker:

I hope you’ve enjoyed this article. You can follow – and contribute to – on Github, Twitter or subscribe via rss.

Dec 11, 2015