Android Core

6 Steps To Develop And Publish an Android Library

Developing an open source Android Library is a great experience. You have the chance to pay back with your work all the times you used an open source library. There are a lot of libraries that we all used and that have simplified our developer life. It is, also, a great opportunity to learn because the source code is public and all other developers can check it and use it and for sure, you will get some feedbacks. You, as a developer, have to be ready to get positive and negative comments, opinions, suggestions, all these help you to get a better developer. You earn, during this exciting developing process, a huge experience listening to other developers opinions, comment. So if you have an idea develop it and make the code open source, you will benefit.

This post summarizes the main steps to follow (or that i followed) when developing an open source Android library.

  • Find the idea
  • Find the repository
  • Create a website
  • Create a community
  • Publish the library
  • Control your repository

publish_android_opensource_library

Step 1: Find the idea

The starting point is finding the idea, the right idea. There are a lot open source library and each one has its own features. Generally speaking, there are two different options:

  • if you have a great idea about something that is not covered then you can develop your library
  • otherwiseyou can contribute to an existing library and try to improve it.

You could have a third option: rewriting and improving an existing library adding some new features or using new technologies.

To get the inspiration, you can give a look at android-arsenal.com, a great site that holds the most important libraries.

You can check there  to know if your idea is original or there is already some like that.

Step 2: Find the repository

Once, you have the idea it is time to find the right repository where to store the library code. There are several options, my favourite is Github because it is very simple to use and  free.

The account is free as long as you manage a public repository and this is the case we are covering. Using Github, you can manage all the library developing process. To not make things too complicated, it is enough to create two branches:

  • master branch
  • dev branch

The main branch is where you store the stable code when you “release” the library source code so that other developers can download and use it.

The dev branch is the branch under development where the code is not stable until you move it to the master branch.

The are some other interesting features that help you to manage the Android library source code like milestones and releases.

Step 3: Create the website

This step is not necessary but helps other developers to know your library and how to use it.

You can release such information like wiki using Github wiki-pages or you have the option to create a website hosted by Github.

In this case, you have to create a branch called gh-pages where you add your HTML/scripts files. This site should contain relevant information about the Android library, the main features, why it is different from others and why a developer should use your library.

You should add also information about the current library release and about the source code: how it is structured and how to modify it.

Do not forget to specify library dependecies if it exists.

Step 4: Create a community

Once you have released the first version of your library, you should create a community so that users and other developers can discuss topics related to your library and you can get useful information about new features. There are several ways to create and handle a community, my preferred one is using G+. Creating a G+ community is very easy  and once the community is ready,  invite your friends to join it. The G+ community is a great place to discuss Android Libray bugs or listens to users improvements.

android_community_opensource

Do not forget to link the community in the website.

Step 5: Publish the library

This is not a trivial aspect. When you publish the Android library makes it available to “all the world”. The publishing process of an Android library is quite complex and requires several steps, but it makes the library easier to use.

Developers do not want to fight against the library source code to make it working. You have the choice to leave it simply as source code and developers that want to use it, check out the code, import it into their projects.

If you want to do something more advanced you can use Sonatype repository.  When the Android library is in sonatype repository the library can be referenced in the gradle file like:

dependencies { 
  compile 'your_id:lib_name:version'
  ....
}

The last option is using Jitpack.io and interesting solution that simplifies the publishing process and it can be easily integrated with Github. You have to create a Github release and without much work the library is available at maven repository so that the Android library can be referenced in gradle file.

Step 6: Control repository

One important step is controlling your repository. Once the Android library is available and users start developing projects using it, your library could have some bugs, so other good-willing developers start fixing such bugs and they create pulling request in Github.

One way to control the consistency of your repository and to avoid compiling errors when you commit changes is using
Continous integration or CI. CI tools are systems that check the library source code verifying if it still compiles or not after some changes are made.

One great tool is Travis-ci. It is integrated with Github and using the same account you can create an account. Travis-ci requires you to create a build file used to guide the compiling process.

Every time the source code in Github is modified the compiling process starts and you know soon after the result.

This is my two cents worth.

Francesco Azzola

He's a senior software engineer with more than 15 yrs old experience in JEE architecture. He's SCEA certified (Sun Certified Enterprise Architect), SCWCD, SCJP. He is an android enthusiast and he has worked for long time in the mobile development field.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button