Image is taken from https://www.spaceotechnologies.com/

Publishing android libraries to Jitpack with Gradle 7.+

Siddharth Singh
ADGVIT

--

Android frameworks and libraries (or just libraries in general) are a set of implementations of behaviour that are written in programming languages and have a well-defined interface. Android libraries are developed and published to help out the developers and ease the process of building android apps.

Gradle 7.+ is the next step in Gradle’s evolution in build automation and developer productivity. With the latest release of Gradle and its modules, the process of publishing an android library is slightly changed.

In this blog, I will be talking about how we can publish our android library to Jitpack with our Gradle version being 7.+.

To learn how to publish an Android library, we first need to create one. So shall we begin?

Creating Android Library

Step 1. Lets us start by creating a standard android project and let us name it MyLibraryExample.

Creating a standard android project.

Step 2. Now create a new module from File → New → New Module… Select Android Library from templates and provide the module name.

Creating a new module.

Step 3. Your project structure must look like this. You can include all your Java classes, XML Layouts, drawable, fonts, etc. inside this newly created module.

Note: If your are unable to find res directory, you can simply create one and add Android Resource Directories inside of it.
Project Structure

Step 3. Here comes the most important step. Once you have added all the required code for your library, you need to create a new file, jitpack.yml inside the project-level directory. Add the following code inside the newly created file.

jdk:
- openjdk11
before_install:
- chmod +x gradlew
install:
- ./gradlew build :MyLibrary:publishToMavenLocal

Step 4: Now edit your module-level build.gradle as follows and after editing it must look something similar to this:

Now inside settings.gradle add the following code snippet:

repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}

Click on Sync.

Congratulations you have successfully created your library. Now we need to publish it.

Publishing Library to Jitpack

Step 1. Create a new repository on Github and push all your code to the repository. Create a new release.

Create a release after uploading code to repo.

Step 2. Now go to Jitpack and paste your repository link and click Look Up. Now select the release version and click on GET IT. Check the Logs for any errors. You can refer below to the same page to learn how to use your library.

Publish your library to Jitpack.

Congratulations, you have successfully created your first library. Share it with your friends.

Thanks for reading the article make sure to save this article and shower some claps if you like it. Stay tuned for more exciting articles like this one. Till then enjoy coding! 🚀 🔥

Contact Me: Github

--

--

Siddharth Singh
ADGVIT
Writer for

As a tech enthusiast, I ventured into development, bridging imagination and code through research, experimentation, and blog posts, offering insights.