Create your own Android Library

Ishan Fernando
MindOrks
Published in
3 min readMay 30, 2018

Most of the (Actually everyone) android developers use 3rd party android libraries to implement some function quickly and efficiently. Did you thought how the other developers developing these kind of libraries? …. So today I will show you the way of developing small library and publish it to github….. Then how that library make available others to download and use for their own projects.

When publishing our library, there are some distribution platform are available to make your life easier. I assume most of the people are heard about jcenter. We can use jcenter to publish our library. But it is very costly. But I found another cool platform called Jitpack . This platform is pretty cool and we can publish a library within a second.

First create a Normal Android Project as we usually do. File -> New -> New Project. Add the Project Name and create a project.

Next you have to add Library Module inside your project.For that got to File ->New -> New Module and Select Android Library.

Then add your library name and create a module.

Open the project level gradle and add this code under the dependencies

classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
How file looks like after adding library

and open the module gradle and these code line in to the top

apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.<username>'
How file looks like after adding library

Replace <username> with your github username.

Now push your code to the Github. I hope you know about pushing code to Github. If do not know you can simply google it.

Go to your github account and select the project you created.

Project

Click Release tab.

Click release

Click draft a new release(If it a first release it shows create new release) and add relevant details and click publish release.. booom your are done with publishing your first library module.

Go to jitpack.io and Add your repository url and click look up. then it will show your library with releases. Click get it button. Then it will show show can we add this library to other project.

Search your library here and click get it
This show how can someone add your library to their project

When you are implementing function for library you have implement that function under the library project , not the main one.

--

--

Ishan Fernando
MindOrks

JavaScript | TypeScript | Angular | Flutter | React