Must have things to start new Android Project (Part 1) Languages and Network Libraries

Android Development is evolving very fast. There are many instruments and libraries which can help you develop Android Application. I decided to write series of articles to help people who only start with Android Development to choose the right libraries for their project.

Language

So first of all let’s choose the language. If we are speaking about classical native android development there are two options. You can use Java or Kotlin.

For the experienced Android Developers the choice is pretty obvious. If you ask them, you will hear: “Of course Kotlin!”. For other people this is still something to discuss. So Java is a mature language and it’s still used world wide. Java is synonym of stability and safety. This is a nice language which is still developing and growing. But what if I say that Android uses Java version which was released 6 years ago! So Android Developers can’t use all new cool features from Java 11.

In modern Android Development even one outdated technology could bring a lot of problems, increase the technical debt for developers and for the whole business as well.

Kotlin is a safe modern language which has a full compatibility with Java and brings Android Development on the next level.

Network library

So we’ve chosen language, and it’s already a lot. Now I assume that our new Android Project needs internet connection to communicate with remote storage. It doesn’t matter what you use for backend — remote server or Firebase from Google, you might need something to connect to it from the client side. Here are the options to consider:

  1. Retrofit

First commit of this library was made on 7th of September 2010. So the library is already well known in Android Development world. The purpose of this library is to make simple and nice API to perform requests to the server.

This library is flexible which means that you can set it up as you want. You can use one of the range of converters to parse your response: Guava, Gson, Jackson e.t.c. Basically there are different options how to receive the request. It’s possible to use default Call object or RxJava Observable. Also Retrofit is mostly written in Java but still provides some kotlin extension functions which give you an option to use kotlin coroutines. Retrofit was always the first choice for me as a library to make network requests. Here is an example of simple GET request:

2. Volley

Google released this library right after Retrofit and it was supposed to be an official replacement for Retrofit. The Volley documentation is located on developer.android.com website, which makes this libary an official REST client for Android Application. Volley supports all possible request types, provides request cancelation API, easy customisation for retry and backoff. Volley can be used with RxJava and coroutines.

Simple GET request with Volley

3. Fuel

If you want to have something written in Kotlin, Fuel might be an option for you. Obviously it’s possible to use coroutines API, RxJava and all of possible parsers to parse your Response which makes Fuel as flexible as Retrofit. The same GET request:

4. Ktor

It’s not really an alternative. In basic implementation Ktor allows you to make requests. But if you need something more e.g retry or request cancelation you have to write it yourself. Coolest thing about Ktor is that you can use it for Kotlin Multiplatform.

This is nice when there are options to choose. To make a good choice, you need to ask yourself some questions:

  • Is it okay to use Java Library to start new Android project in Kotlin?
  • Do I want to use official instrument or it’s fine to use third-party solution?
  • Do I plan to use this network library as a part of Multiplatform project?

This diagram could help you to make a right choice.

Hope this article was helpful. Follow me to read my new articles about Android Development and Kotlin. Happy coding!

Android Developer, Tech geek