Coding an app can quickly get complicated and messy, but thankfully, other developers have already put in the hours to help you create better apps in less time. Android libraries are a lifesaver, and there are a ton to choose from, so how do you know which one is right for your project? To help you decide, we did a little survey with our developers in-house and came up with this list of the top 10 Android libraries used by Be-Bound developers.
Clean Code and Simplification
EventBus was voted a top Android library by two of our Be-Bound developers, so naturally we’ve put it at the top of our list! Anyone who has ever tried to facilitate communication between components themselves, knows that it can get complicated quickly. EventBus cleans up the mess so that communication is simplified between activities, fragments, threads, services, and more. This library speeds up development by taking away one of the headaches, and the clean code makes it easy to maintain. Using their built-in system means you can rest assured that you’ll have less errors.
2. Android Annotations
We all know code can be ugly… really ugly! The longer and more complicated the code, the more time it takes you to develop your app, and the more chance you have of making a mistake. Android Annotations is made to start you off on the right track. Starting with your first line, your code is clean. As they say, they take care of the plumbing so that you can concentrate on what really matters. The amount of annotations available is huge and easily customizable. For example when you work with threads, Android Annotations suggests several simple annotations that are sure to work well.
RxJava has upset our habits for composing asynchronous and event-based programs. If you’re an Android developer, maybe you’ve heard of RxAndroid, Reactive Extensions for Android? Maybe you’ve even already tested it…But do you know RxBinding? It’s RxJava binding APIs for Android UI widgets from the platform and support libraries, made by Jake Wharton. Easy and powerful, this library, gives you access to all widgets and support libraries, like EditText, etc. with the power of RxAndroid!
An open-source animation toolCreated by Airbnb, Lottie supports AfterEffects features so that your app can go beyond simple animations. This will make your app much more dynamic, with movement that catches the user’s attention where its needed most, and Airbnb has made it so much easier than it used to be! Your app can be user friendly and beautiful, without a lot of effort. Your app will be able to use animations just as easily as static animations.
Debugging and Optimization
You know that good old saying “the canary in the coal mine”? Well LeakCanary is a library designed by Jake Wharton that works as an alert for memory leaks in your app. This helps you to increase your app performance and maybe avoid crashes or bugs. Too many memory leaks add up in your app. When there are extra references pointing to an object, these accumulate and take up unnecessary space on your app, until eventually it crashes. No matter how great your app is, if it’s crashing due to memory errors, you’re going to get bad reviews. LeakCanary helps you detect memory leaks and improve the performance of your app. All you need to do is add about 5-6 lines to your code. Then LeakCanary will send you a popup notification whenever it detects a problem.
This is a powerful debugging library developed by Facebook that helps you understand which HTTP requests your app is executing. It lets you capture network traffic and analyze the internet usage of your app. Once you’ve set it up, an interface will be available directly on Chrome, and when your app is active it shows every request so you can see whether or not the details of the request are ok or not (headers, values, size, durations). With that information, you can detect problems and/or improve the internet usage of your app. It’s very easy to implement: just add a few lines of code into your app and then Stetho does everything for you in the background.
Developing Web Services
For example, if you have any issue in your adapter with ImageView: use Picasso! ImageView recycling is easier and adapter re-use is automatically detected and the previous download canceled.
Need placeholders and various origin resource loading? Use Picasso! Would you like to have complex image transformation ability with minimal memory use? Use Picasso! Resize, crop, etc. all common transformations are available and it’s easy to find transformation libraries dedicated to Picasso. Last but not least, need an automatic memory and disk caching? Use Picasso!
Too many applications are not available offline, so any library that helps improve activity on weak networks is a subject that’s close to our hearts at Be-Bound!
This is a REST client for Android developed by Square, that helps developers simplify calls to REST web services in an Android application. Retrofit enables faster and easier development of network requests. Retrofit hides the messy stuff on the network level (threading and parsing requests). All you do is describe the endpoints, what they expect, and what they respond, and you’re done. It’s a bit complex to use in the beginning, but it’s definitely worth it!
It’s common for Android apps to be linked to an external database. In order to execute SQL requests, the app works with a REST API to access data (usually in XML or JSON). The connection to this API is rarely easy and often requires calling a URL [Office1] with an Http Client and using different parsers to be able to use the results of the call. Retrofit offers a very simple way to make calls. Thanks to an annotation system, writing the calls is much shorter and is easy to understand, making it easy to retrieve or upload JSON via REST. Maybe best of all, it’s no longer necessary to use many different types of parsers. Just create a Java object with the identical field name to your data model and Retrofit takes care of the parsing for you!
Testing and Mocking
Writing unit tests in an Android environment can be frustrating. Robolectric is a solution to avoiding the usual issues with Android SDK and runtime dependencies. It’s a framework that allows you to write unit tests and run them on a desktop JVM while still using Android API. Robolectric replaced all Android classes by shadow objects, giving you control of your unit tests, i.e. the lifecycle! Roboelectric is a unit test framework for the Android SDK originally created by Xtremelabs. Originally created by Xtremelabs, Roboelectrics will speed up your testing!
You need unit testing. You need to mock objects. You need Mockito! Too often, developers run tests with an expectation method, but Mockito saves you the pain of having your expectations fall short. And if your test fails, Mockito clearly shows you where things went wrong. You prepare the mocks and script behavior, then test the selected code, and verify that your mocks encountered the expected results. …and if it doesn’t work, just help yourself to a Mojito