Create your first android library

Ajith v Giri
2 min readSep 1, 2018

--

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.
AndroidLibray

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

api project(:'yourlibraryname')
Imgur

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

Imgur

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.
Imgur

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.

Imgur

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'
}

--

--

Ajith v Giri

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