Publishing Android library using Gradle 7.0 to Jitpack

Soumya Kanti Kar
wwdablu
Published in
2 min readSep 17, 2021
Photo by Fotis Fotopoulos on Unsplash

We always want to keep ourselves updated, and also our code. Updates being enhancements, newer features, performance improvements and breaking changes. Change is inevitable.

With Gradle 7.0 and upwards, using Jitpack requires some change on the application side. Following are the changes that are needed to successfully have a build in Jitpack.

The first is that of JDK11 support. For this, we need to create a file named jitpack.yml at the root of the repository and add the following content:

jdk:
- openjdk11

Make the following change inside library gradle.

plugins {
id 'com.android.library'
id 'kotlin-android'
id 'maven-publish'
}

At the end of the gradle file put in the following changes:

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = "your.package.name"
artifactId = "your_lib_name"
version = 'lib_version'
}
}
}
}

Next, open settings.gradle file and add maven along with the other repositories.

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
...

maven { url 'https://jitpack.io' }
}
}

Once of these changes are done, one up the terminal and execute the following command to verify that it is working fine.

./gradlew publishReleasePublicationToMavenLocal

It should start a gradle daemon and at the end you should be build successful. Once the build is confirmed, push the changes into GitHub, create a new release and watch Jitpack successfully build and have the library available to all the other developers.

--

--

Soumya Kanti Kar
wwdablu
Editor for

Android developer. Interested in working on open source Android libraries and applications.