Skip to content

Top 10 Essential Android Developer Libraries August 2019

With Kotlin being more dominant than ever, Android has grown insanely within the past couple of years! It’s hit that puberty stage where you wouldn’t even recognize it from a couple years ago. With that, in addition to more libraries becoming the norm, architecture being super important, and TDD being a main-stay, the Android coding style has become pretty defined.

With all this in mind, I have rounded up the top 10 most used libraries in the Android ecosystem. Many of these are what you’ll find employers expect of you so get ready to hear some familiar names. Without further ado, here are the Top 10 Essential Android Developer Libraries that every Android Developer must know as of August 2019.

A few disclaimers, the libraries listed here mostly serve different purposes and are usually best when combined together in one way or another, hence, these Top 10 could really go in any order.

10. RxJava

val ratesObservable = Observable.interval(1, TimeUnit.SECONDS)
    .switchMap{ currenciesApi.getCurrencies() }
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .doOnError { view.showError() }
    .map { result ->
        return@map result.rates
    }
    .subscribe { rates ->
        doStuffWithRates()
    }

Making an API call every second with RxJava

RxJava is the Java (and Kotlin) implementation of the ReactiveX API for asynchronous programming with observable streams. As an extremely efficient way to download and manipulate data, you can chain these observable data streams and make use of countless operators to have absolute full control of your data.

RxJava especially shines when you have to fetch data in real-time. Real-time-related problems such as needing the output of one download for the input of another download becomes a walk in the park for RxJava due to the way it can chain and map its results.

It does have a steep learning curve, but this library only gets more powerful as you get more familiar with it and its operators. Add on some masterful thread switching and error-handling, it’s no wonder RxJava deserves its place in this top 10 list.

Link: https://github.com/ReactiveX/RxJava

9. Glide

Glide
  .with(myFragment)
  .load(url)
  .centerCrop()
  .placeholder(R.drawable.loading_spinner)
  .into(myImageView);

Loading an image with Glide to an ImageView

The standard way that Android loads image and video resources locally or from download isn’t the most efficient way for the system. The best doer of that task has been a war between Picasso and Glide, and Glide seems to be winning.

As said in its Github page, Glide is a media management and image loading framework for Android that wraps media decoding, memory and disk caching, and resource pooling into a simple and easy to use interface. It supports fetching, decoding, and displaying video stills, images, and animated GIFs. What better way is there to put it?

Link: https://github.com/bumptech/glide

8. Android KTX

// Commit a new value synchronously
sharedPreferences.edit(commit = true) { putBoolean("key", value) }

Using SharedPreferences with Android KTX

Android Jetpack is huge and pretty amazing, but if I had to choose one library in there to make it in this list, it’s Android KTX due to how great these Kotlin Extensions are.

As if Kotlin didn’t simplify things well enough already, Kotlin code just became even more concise for a variety of functions that include Preferences, Fragments, SQLite, ViewModels, and even Reactive Streams! For the full list, I recommend you check out the link below.

Link: https://developer.android.com/kotlin/ktx

7. Leak Canary

Stack trace delivered. Sincerely, Leak Canary

As projects get closer to their production releases, we start to worry more about app performance. Only when we start analyzing the app at that point do we find there were a multitude of things affecting our app’s performance.

Leak Canary lets us know when resources get leaked while the app’s running so we can take out the trash before it stacks up to a monster pile of garbage. The library is setup so this functionality is only shown on the front-end in debug releases of the app, and we even get a nice stack trace with our leak report.

Link: https://github.com/square/leakcanary

6. Firebase

A couple of Firebase’s many services

Firebase is an all-in-one cloud solution where each tool comes as a service. This includes, Authentication, Crashlytics, Cloud Database and Storage, and A/B Testing among plenty of others in a continuously expanding list.

This is amazing for indie developers as it provides these services free up to a certain quota by which you’d need to start paying. For some business models, these prices could even prove cost-effective. Even if this isn’t the case, I’d be surprised if there isn’t a single tool out of Firebase’s debug and marketing catalog that an app could find useful.

Link: https://firebase.google.com/

5. Timber

Timber.wtf("Wtf is happening with this app")

A simple Timber wtf call

Timber is the Logger library we never knew we needed. When we’re ready to ship our app, we don’t want to ship our logs with it. That’s just wood we don’t need. What do we do then? Search and destroy our logs? Comment them out?

Timber simply doesn’t log messages out in release builds of the app. Well, more precisely, we can create different Trees for debug and release builds of our app which determines the logs that get sent out. It also does away with having to create LOG_TAGs for every class we want to log in.

On top of all this, we get more advanced logging functionality like storing logs in persistent memory or sending it through your crash reporting tool of choice… like Firebase Crashlytics per say.

Link: https://github.com/JakeWharton/timber

4. EventBus

EventBus.getDefault().post(MessageEvent())

Posting an event with EventBus

Activities, fragments, threads, and services are all Android components. They communicate with each other in an infinite number of forms defined only by the way we program them. This can get messy and makes components quite tightly coupled.

EventBus simplifies this communication. A component needs only to register to the EventBus object and it can start listening for events broadcast from anywhere in the app, just like tuning in to a radio frequency.

This of course adds the benefit of simpler and less code, looser coupling, and even includes more advanced features like delivery threads and subscriber priorities.

Link: https://github.com/greenrobot/EventBus

3. Mockito

@Mock
lateinit var mockedList: ArrayList<String>
 
@Test
fun whenUseMockAnnotation_thenMockIsInjected() {
    mockedList.add("one")
    Mockito.verify(mockedList).add("one")
    assertEquals(0, mockedList.size)
 
    `when`(mockedList.size).thenReturn(100)
    assertEquals(100, mockedList.size)
}

Testing a mock implementation of an ArrayList with Mockito

JUnit and Espresso are both super important Android testing libraries, but since they’re already included by default in most Android projects by Android Studio, I feel like it would be cheating if I included them here.

Mockito on the other hand is no less important than those two, and it’s an absolute must in every Android developer’s toolset as it allows one to create mock implementations of objects in your application in order to test their behavior and make sure everything’s working. Why? Because we can test objects loosely from all the dependencies they rely on. Their behavior is mocked.

Mockito can get quite in-depth, but it’s quite simple on the fundamentals which offers quite a lot in the realm of testing.

Link: https://github.com/mockito/mockito

2. Dagger 2

class Tesla @Inject constructor() {
    @Inject lateinit var car: Car
    @Inject lateinit var electricity: Electricity

Setting a Tesla’s objects as injectable dependencies

Android classes tend to depend on each other quite a lot. We need an instance of one class in another class which is needed in another class (and on and on and on). This chain gets huge!

Dagger 2 controls all of this by having a central distributor of dependencies. If one class requires an instance of another, it requests the Dagger object for that instance, hence, the classes are loosely coupled. This comes with all the benefits of better testing, reusability, performance and concision.

On top of all these benefits, this makes you look like you know your shit. If you want to look like an amazing developer, definitely learn this.

Link: https://github.com/google/dagger

1. Retrofit

@GET("posts")
fun getPosts(): Call<List<Post>>

Making an HTTP GET call with Retrofit

Retrofit is a type-safe HTTP client for Android. It essentially turns your HTTP API into a Java interface. In layman’s terms,  it makes loading APIs into POJOs ridiculously simple. You simply need to create an interface and in it, annotate your API-calling functions and Retrofit automatically transforms it into the API call it needs to be.

Retrofit also offers URL Manipulation, Query Parameters, Request Bodies, and Multipart requests. It also works amazingly well with RxJava as API results can come in the form of Observable streams.

APIs are used everywhere not only in Android but across most forms of software out there. It would be a sin to not know how to use this powerful library moving forward. For this reason, even though I said this list isn’t ordered, I do believe Retrofit may truly deserve the number 1 spot on this list.

Link: https://square.github.io/retrofit/