Create your first android library

An Android library is like JAR files, the Android ARchive(AAR) bundle is the binary distribution of an Android Library Project.

Apart from JAR file, AAR contain resources as well as compiled byte-code and assets are not supported. we can make library modules which can be used as dependencies in Android projects.

1.Getting started

In Android Studio each library is a module. To create a new library module in an existing Android project.

select  File ▸ New ▸ New Module and select Android Library.

After successful build please ensure library is added to your existing project dependencies.

api project(:'yourlibraryname')

2.Create classes & resources for the library

I have created a library named infinityscroll which is used for pagination in RecyclerView. infinityscroll consist of two classes, both are accessible to the main app module

3.Share the project in GitHub.

Upload the created project to GitHub and create a release for your library.

Add version tag & title then click publish release.

4.Publishing the library

The final step go to jitpack.io and sign in with your GitHub account. You see the GitHub repositories on the left side choose it from there or you can type/paste the project GitHub url in the textfield.

Finally

Finally you’ll get the dependency of published library like this

repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.ajithvgiri:recyclerview-pagination:v1.0'
}

--

--

--

Mobile app developer with an eye for design.Loves to create apps with good UI/ UX that doesn’t annoy people.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ajith v Giri

Ajith v Giri

Mobile app developer with an eye for design.Loves to create apps with good UI/ UX that doesn’t annoy people.

More from Medium

Kickstarting Ads Kit by integrating Interstitial Ads in Application (Kotlin)

Android Spotless Easy Setup

Temperature Converter App: Android Kotlin App

Create Upload Service for Amazon S3 in Android