Libraries are used in most, if not all, projects. They help us to develop software, save time and facilitate work. However, it is not easy to choose a library, as there are a number of them, and often several libraries are designed to solve the same problem. Different Android libraries have advantages and disadvantages. In this article we will look at them in an objective manner and think about how to avoid getting confused. First of all – is it worth reinventing the wheel in our projects?

Android libraries – yes or no?

There are plenty of possibilities for developers. As I mentioned, we can choose between many solutions to given problems:

  • OkHttp, Retrofit, Volley – REST API support,
  • Picasso, Glide, Fresco – picture downloading and management,
  • Dagger, Coin, Kodein – dependency injection,
  • Realm, ObjectBox, Room – Database service,
  • Moshi, Gson, Jackson – JSON parsing,
  • RxJava, RxKotlin, RxAndroid – stream support, reactive programming.

“Application development involves combining these solutions into one whole to have as little work in the project as possible” – we can come across such a statement more and more often. Is it true, and is it really worth using all these facilities? Or perhaps libraries are overrated and lead to more problems than benefits?

Android libraries – why are they worthwhile?

Fragmentation

One of the biggest problems in writing applications for Android devices is so-called “fragmentation”. This means that the application, or rather the written code, does not behave the same way on all Android devices. Most device providers modify the system significantly according to their needs. When making such modifications, they sometimes change the functioning of some system functions, sometimes to a great extent. They may also stop working completely. In addition, it is worth bearing in mind the variety of versions of the system that need support in the application. Libraries address this problem because their providers improve and adapt them to changes in the system.

Reinventing the wheel

Another reason is “reinventing the wheel” – as taken from the title. Is there any point in writing solutions that already exist and are used by millions of users around the world? The majority of popular libraries are used in hundreds, if not thousands, of applications in the store. These, in turn, often have tens or hundreds of thousands of users. By using such code, we are sure that we will be able to avoid problems that could arise if we tried to write the given functionality on our own.

The clock is ticking…

The last, but still a very important reason, is saving time. Even the best developers can make a mistake while writing code. If you add a few words that developers are familiar with, such as “deadline” and “ASAP”, it turns out that saving time is an important reason to use ready-made libraries. We cannot deny that using ready code, especially if we have used it before, will save us many hours which we would otherwise spend writing this code from scratch. We can be sure that the quality of the code will not suffer, as we take advantage of the benefits of proven code used by thousands of developers around the world.

Android libraries – disadvantages

No support

Libraries are not infinite. Given solutions are no longer up-to-date and developers are choosing newer approaches. Often, the library providers themselves create another version of a given library or suspend further support and development for various reasons. This can be a problem when there is no one to offer further support for such code and repair errors that may arise with new systems or devices.

Fortunately, despite the fact that they are open-source tools, behind many popular libraries there are major companies like Facebook (Fresco library for photo support) or Square. Such libraries are usually supported even when work on them is completed. The RxJava2 library is such an example. Despite creating version 3.0, its providers claim that they will support it until the end of February 2021!

Smaller libraries equal uncertain support

When choosing a library, it is worth taking into consideration its size and support. In the case of smaller libraries, when there are no well-known people from the world of technology standing up for them, their providers can be unable or unwilling to work on them any longer. When we carry out a project that will have to undergo development for years, the end of support can be a real problem. How to cope with it then? The developer may try to maintain the library on his own, improving the code based on errors found by users, to ensure that it works correctly. However, here and in many other solutions, we may be limited by licensing issues.

Fortunately, when choosing a license for their software, many library providers decide on one that allows them to be used both in projects with paid closed source code and those with public access. Furthermore, the license very often also allows you to modify and redistribute the library code without any issues. An example, and in my view the most frequently chosen license, is Apache License 2.0.

Barriers to entry

So-called barriers to entry are also a risk when using libraries. The point is that not every new project team member has previously used a given solution. Therefore, it will take some time before they start using it fluently. This is troublesome, of course, but the same is true of the application code written by developers. Every new person joining the project must be familiar with the way it is developed.

Application size

Method limit

The last counterargument that comes to mind is the size of the application. There are two problems here. The first concerns the limits to the number of methods an application can have before it exceeds the allowable size of the .dex file (Dalvik executable). This problem occurs when we exceed 65,536 methods. This value seems to be inconceivably large and it doesn’t seem possible to exceed it, but it often happens in projects that are:

  • large,
  • incorrectly configured,
  • old.

Android provides many solutions to this problem, of which ProGuard is one. It allows you to remove unused methods and classes, including in libraries. Another solution is to run multidex support for the application.

The real size of the application

The second problem is the real size of the application. Library providers do their best to help developers by dividing their libraries into several components. Not all of them require additions to the actual application. Some of them are only required during the application building process, and are not used later on. The correct configuration can also help – then we can remove some dependencies and files from the library if we don’t need them.

Summary

We use ready-made libraries because of the ease and convenience of use. However, before deciding on a particular one, it is worth considering how to use its full potential. Libraries enable us to save time and extra effort. I wanted to take a closer look at them in an objective way. Although they do have some defects, I don’t think anyone would like to have to write such functionalities as managing pictures, network connections or any others that can be found in the most popular libraries. In my experience, it’s not worth deciding on a big library that solves a lot of problems, and then using only a shred of its capabilities. It is better to choose a library that solves one specific problem or a set of the same type of problem. Also, try to choose libraries which are suitable for the project. If we are sure that projects will be maintained and developed, we can use libraries from certain providers for a very long time.

Author:
Artur Szymański

He has been an Android Developer for 8 years now. Despite many years of experience in the industry, coding is still his big passion. Currently altogether with JCommerce improves the world of Android applications. In private life, an enthusiast of cats, not only those small. He owns a beautiful Turkish angora.

Comment

CONTACT US!

Would you like to learn more about the possibilities of cooperation? Do you have a question? Write to us!

I hereby agree that JCommerce Sp. z o.o. shall process my personal data (hereinafter ‘personal data’), such as my name, surname, e-mail address, telephone number and company name, for commercial purposes.
I hereby agree that JCommerce Sp. z o.o. shall process my personal data (hereinafter ‘personal data’), such as my name, surname, e-mail address, telephone number and company name, for marketing purposes.
I hereby agree that JCommerce Sp. z o.o. shall process my personal data (hereinafter ‘personal data’), such as my name, surname, e-mail address, telephone number and company name, for recruitment purposes.
I hereby agree that JCommerce Sp. z o.o. shall process my personal data (hereinafter ‘personal data’), such as my name, surname, e-mail address, telephone number and company name, for future recruitment purposes.
I have been informed by JCommerce Sp. z o.o., 3 Ks. Piotra Sciegiennego St. 40-114 Katowice – the personal data controller – that: - The provision of the aforementioned personal data is voluntary but essential for commercial purposes if I have chosen a request for proposal, or recruitment purposes, if I have chosen the remaining options;
- I have the right to access the content of my data, including to receive copies of it and correct it, delete it and limit the processing of it, as well as the right to transfer it, the right to object to the processing of it, and the right to withdraw my consent at any time. However, the withdrawal of my consent shall not affect the lawfulness of processing carried out on the basis of the consent in question prior to its withdrawal;
- A statement of withdrawal of my consent to the processing of personal data should be submitted to the headquarters of JCommerce Sp. z o.o. or sent to the following e-mail address: zgody@jcommerce.pl. The withdrawal of consent to the processing of personal data shall result in the inability to fulfil the aforementioned processing purposes;
- The personal data provided shall be shared by JCommerce Sp. z o.o. with the company’s authorised employees and individuals collaborating with JC under civil-law contracts, who are involved in the implementation of the purpose of the processing;
- The data provided shall be processed on the basis of the relevant provisions of Regulation (EU) 2016/679 of the European Parliament and of the Council of 27 April 2016 on the protection of natural persons with regard to the processing of personal data and on the free movement of such data, and repealing Directive 95/46/EC (General Data Protection Regulation), ‘GDPR’;
- Should you have any questions regarding the protection of your personal data, please contact us by e-mail: odo@jcommerce.pl;
- The personal data provided shall be processed for the purpose for which it was supplied, or until I express my objection in this regard. In the event of filing an objection, JCommerce Sp. z o.o. shall no longer process my personal data for the aforementioned purposes, unless it can demonstrate that there are valid and legally justified grounds overriding my interests, rights and freedoms or my data is necessary to establish, pursue or defend a claim, if any;
- I have the right to file a complaint to the supervisory authority if I consider that the processing of the aforementioned personal data violates the provisions of the General Data Protection Regulation of 27 April 2016.
I hereby agree that JCommerce Sp. z o.o. shall process my personal data (hereinafter ‘personal data’), such as my name, surname, e-mail address, telephone number and company name, for commercial purposes.
I hereby agree that JCommerce Sp. z o.o. shall process my personal data (hereinafter ‘personal data’), such as my name, surname, e-mail address, telephone number and company name, for marketing purposes.
I hereby agree that JCommerce Sp. z o.o. shall process my personal data (hereinafter ‘personal data’), such as my name, surname, e-mail address, telephone number and company name, for recruitment purposes.
I hereby agree that JCommerce Sp. z o.o. shall process my personal data (hereinafter ‘personal data’), such as my name, surname, e-mail address, telephone number and company name, for future recruitment purposes.
I have been informed by JCommerce Sp. z o.o., 3 Ks. Piotra Sciegiennego St. 40-114 Katowice – the personal data controller – that: - The provision of the aforementioned personal data is voluntary but essential for commercial purposes if I have chosen a request for proposal, or recruitment purposes, if I have chosen the remaining options;
- I have the right to access the content of my data, including to receive copies of it and correct it, delete it and limit the processing of it, as well as the right to transfer it, the right to object to the processing of it, and the right to withdraw my consent at any time. However, the withdrawal of my consent shall not affect the lawfulness of processing carried out on the basis of the consent in question prior to its withdrawal;
- A statement of withdrawal of my consent to the processing of personal data should be submitted to the headquarters of JCommerce Sp. z o.o. or sent to the following e-mail address: zgody@jcommerce.pl. The withdrawal of consent to the processing of personal data shall result in the inability to fulfil the aforementioned processing purposes;
- The personal data provided shall be shared by JCommerce Sp. z o.o. with the company’s authorised employees and individuals collaborating with JC under civil-law contracts, who are involved in the implementation of the purpose of the processing;
- The data provided shall be processed on the basis of the relevant provisions of Regulation (EU) 2016/679 of the European Parliament and of the Council of 27 April 2016 on the protection of natural persons with regard to the processing of personal data and on the free movement of such data, and repealing Directive 95/46/EC (General Data Protection Regulation), ‘GDPR’;
- Should you have any questions regarding the protection of your personal data, please contact us by e-mail: odo@jcommerce.pl;
- The personal data provided shall be processed for the purpose for which it was supplied, or until I express my objection in this regard. In the event of filing an objection, JCommerce Sp. z o.o. shall no longer process my personal data for the aforementioned purposes, unless it can demonstrate that there are valid and legally justified grounds overriding my interests, rights and freedoms or my data is necessary to establish, pursue or defend a claim, if any;
- I have the right to file a complaint to the supervisory authority if I consider that the processing of the aforementioned personal data violates the provisions of the General Data Protection Regulation of 27 April 2016.