7 Android Libraries Every Developer Should Know About

7-Android-Libraries

‍In this article am sharing with you 7 Android libraries every developer should use to enhance the application from different perspectives.

When developing in Android, usually you have to deal with several requirements, such as doing restful Api calls, data serialization, loading and processing images as well as development related matters like project structure, optimizations, logging and more.

Dealing with such problems usually require a huge amount of time if you are willing to write your own implementations manually.

But why reinvent the wheel?

There are already tens of great free open source Android libraries, in which the open source community people already spent tons of hours developing and contributing to these projects to come up with robust, useful and almost bug free android libraries to be helpful for all the developers worldwide.

And they spend even more time supporting and solving the raised issues.

You will definitely notice a dramatic improvement in your code quality, application performance and development productivity after you learn and start using the libraries I am mentioning in this article.

So here are the 7 Android Libraries unveiled:

 

Gson

gson

The super lightweight library to manipulate JSON Objects inside Java. It provides super easy methods to serialize and deserialize Java objects to and from JSON

Gson plays well with Java Generics and can be used with both Java models from your application module, or 3rd party libraries.

Gson mainly provides 2 methods fromJson() , and toJson() . The former converts a Json string to a Java model as provided in the method’s second parameter type. The latter does the inverse, it converts the given Java model to a Json string.

To start using Gson in your Android code, you only need to include it into your build.gradle file as below:

To learn more about Gson library and its features, with sample code and Api guide, press here.

 

Dagger

dagger2

This is best library to implement the Dependency Injection (DI) pattern into your application.

There are already other android libraries that can help you achieve the DI pattern like Robo Guice (Deprecated as of August 2016), Butter Knife or Android annotations. Each of these has its pros and cons.

And in my opinion, I see that Google’s Dagger version 2 , provides the best option when it comes to implementing a robust and well-structured dependency injection pattern.

Previously, there have been 2 versions of dagger library from both Square Inc. and Google.

Square’s version of Dagger 1.x is now deprecated and no longer maintained.

Google has built on top of Dagger 1 and is now maintaining Dagger 2, which brings a great development and performance improvement on the framework, with a compile-time validation of the object graph, full trace-ability, easy debugging of provision and creation and more improvements.

To use Dagger 2 in gradle:

This only reveals the tip of the Dagger 2 iceberg,  there is a lot to learn about this great library. You can start from here.

 

Retrofit

retrofit2

The most convenient way to do http(s)-based Restful API calls. Retrofit is a type-safe Http Client that is built on top of OkHttp library.

It provides an easy and simple way to introduce your API endpoints using attributes that should be defined inside a Java Interface, and then you instantiate the Retrofit instance with its builder method, after that you implement the method call, and attach a callback object, which will override 2 standard methods: onResponse , and onFailure

Retrofit gives you the ability to modify the header objects of the request, add interceptor for the request chain, implement custom authenticator and custom model converter factory.

To start using Retrofit, first you need to include library reference in your build.gradle file:


Check Retrofit website to continue learning.

 

Android Ion Library

android ion

Android Asynchronous Networking and Image Loading, Ion provides you a fluent API code to do a set of asynchronous tasks related to API calls, downloading files, loading images into ImageView.

All ion operations return Future Object and can be gracefully cancelled.

In fact, Ion combines the features of multiple android libraries into one. It is a great way to achieve the tasks of doing asynchronous api calls, loading images, downloading files, cancelling requests and many more.

To use Ion library, add a reference to it as the below:

If you are interested in learning more about Ion Library, check its GitHub Repository

 

Crashlytics

crashlytics

A product of fabric.io which was acquired by Google since January, 2017.

Crashlytics is the ultimate crash reporting and monitoring tool.

The administration web portal provides comprehensive information about crashes and users. It provides a real-time view of crashes, with a full deobfuscated stack trace of the crash, the device type, OS version. It also gives geographical information about the user who had the crash.

To integrate Crashlytics inside your app, there is an Android studio plugin for fabric that can be installed.

To install the Fabric plugin, go to File -> Settings -> Plugins , and then in the search bar type ‘Fabric’ , you will get the option ‘Fabric for Android Studio’ , then choose ‘install’ , and follow the instructions afterwards.

Once done , you will start seeing a Fabric tab view in your Android studio, from there press ‘sign up’ to create a new fabric account, it will take you to fabric.io account creation page, from there input the account details you want, then finish the setup.

Once you confirm your account, enter your credentials into Android studio fabric view, and then from the products list, choose Crashlytics.

Follow the on-screen instructions to finish integrating your android app with Crashlytics.

For more details, installation instructions, and code examples, check fabric.io website.

 

Picasso

picasso

Instead of loading an image directly into an ImageView, why not do it asynchronously?

Picasso gives you the option to download an image from a url and then display it into the ImageView without you having to block the UI while waiting for the image to get downloaded, the ImageView itself will display a small loading spinner, and once the image gets ready, it displays it seamlessly.

Picasso also features adapter downloads, image simple and custom transformations, download and error placeholders and more.

To use Picasso library, just include it in your gradle’s dependencies section:

To learn more about Picasso, check this link

 

Robolectric

robolectric

A unit testing framework that enables running the unit tests inside JVM instead of running them on emulator or real device.

Robolectric tests can handle many native operations such as view inflation and resource loading, that you cannot achieve with normal JUnit tests, so this gives you a near experience of testing on a real device or an emulator.

To start writing Robolectric unit tests, you first need to include the Robolectric library into your gradle file.

If you are using Android Studio 3 Alpha 5 version or higher, you will need to include the resources merging as part of your gradle test options alongside with referencing the library itself.

Annotate your test with the Robolectric test runner:

See Robolectric.org for a complete guide to learn more about this industry-standard unit testing framework.

Conclusion

You need always to focus on delivering quality android apps in timely manner. The digital age is already fast forwarding and everyday there are hundreds of apps being pushed to Google Play store.

The challenge is growing and the urge to have fast paced iterations of app development is significantly rising.

To be able to catch up with the digital transformations’ high-speed train, you need to be a proactive developer, which means you should always keep on the look for the best android libraries and tools that will improve your productivity and enhance the app development experience.

Make sure to choose your tools, SDKs and libraries wisely.

I recommend that you also read my article of 9 Bulletproof ways to become a better developer.

This is a comprehensive article about all the things you can do to improve your technical skills and become better and proactive developer.

I have included 7 of the most essential and useful android libraries for developers to learn and use .

I might be missing some more important libraries , please share it in a comment so all of us can learn from each other.

 

Bonus

For this important topic , I would like to share this captivating music which is

“Water Music – Suite number 2 in D major. Movement 12”  by George Frideric Handel

Enjoy it 🙂

 

 

Leave a Reply