Publish Library for Android Projects

Use an android library to reuse the code in every project.

Photo from Pexels

What is an Android library? And Why we need it? Check

Android library is the same as an app you code, corresponding source code structure, manifest file, and resource file. The main difference is it will compile in AAR instead of APK. That can be used in Android Gradle the same as other dependencies in Android Source code. And the AAR file can not be altered.

We(Developer) need to use some code in one project, which required for another plan also, but we don’t want to waste the time to rewrite the same system. For that development, we use the library like; loading image, calling network requests, saving files, etc.

Create a library using Android Studio

Android studio is a developer by Jetbrains, which is lead in IDE development in the market, and it has all support from Android Community. It is handy to create an Android library in just simple steps.

File -> New -> New Module -> Android Library

Adding module as Android Library

Here you can select and add a new module as an Android library and add all details like name and package name(need to different from main app package). After successful syncing, add the library as a dependency in the Android project.

Now we have a library in our code. Add coding in your library module and push the code in Github(As I am using this).

After all of the code is pushed on git and tested you can release the first library in Github from release tab.

After releasing on GitHub, open the Jitpack and login with the Github there. After login lookup for your repositories using the link, you copied from GitHub.

Lookup for the repo in Jitpack.io

After clicking on lookup, you will get the all release there and click on the “get it,” and jitpack will compile and release the jitpack Gradle file.

When you will able to see note SVG below the LOG column, that means your library has run(compiled) successfully and published on jitpack. You will be navigated to the Gradle share link and text to implement the library in android project.

This means your library has been published to jitpack and you can put this in your Github readme section for other developers. you can check this Github

Android Developer, Freelance, Enthusiastic Learner