Publishing android library using GitHub and JitPack

This is story about easy publishing own android library for future usage through Gradle implementations

Firstly, we need to create a new module. In case of simple business logic, we can create a pure “Java or Kotlin Library”. But if code depends on some Android stuff (like Context or View), we need to pick @Android Library”.

After that, move all code, which we want to extract, to this new module. Also we can modify module’s build.gradle file and remove all dependencies, not related to our code.

Than, add a maven-publish plugin into a plugins section of module’s build.gradle file:

plugins {
    id "maven-publish"

and also configure this plugin:

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                from components.release
                groupId = "com.github.criticalgnome"
                artifactId = "recycler-view-dsl"
                version = "1.0"

Now we need to create new file jitpack.yml in project root:

  - openjdk11
  - ./scripts/

After that we can push project into public GitHub repository, create new release (with adding correct tag):

After successful creating release, we need to copy repo URL (like and paste it into

After finishing all processes, we can use our brand new library in any our projects:

allprojects {
    repositories {
        // ...
        maven { url '' }


dependencies {
    // ...
    implementation 'com.github.USER:REPOSITORY:TAG'

That’s it! Example code can be found on my GitHub.

Leave a reply

Your email address will not be published.

You may also like

More in:Android