27 Sep 2018
By Belle

What's in your Larder: Libraries for Kotlin Android development

I've recently started exploring Android development in Kotlin, and I've been enjoying it a lot. Coming from Swift, Kotlin has a lot of really similar syntax, which is helpful. I'm brand new to Android development, so there are probably lots more useful libraries I haven't had a chance to explore yet, but these are some that I've saved to my Larder account that I've already found useful, or am planning on trying out soon.


Kovenant is a promises library for Kotlin. I use PromiseKit in most of my iOS projects these days, so I wanted to find something I could rely on for using promises in Android. Kovenant seems to cover most of the use-cases I need (I haven't found an equivalent to PromiseKit's recover function yet, but that's the only gap I've noticed), and it's really nice to use.


If you handle downloading and displaying images at all, Picasso makes this super easy. As well as handling asynchronous downloading and caching of images, you can add transformations, like so:

Picasso.get().load(url).resize(50, 50).centerCrop().into(imageView)

I also use this picasso-transformations library to make it easy to add extra transformations to Picasso, such as cropping to a circle shape.

For what it's worth, I recently found out Google recommends Glide for handling image loading, rather than Picasso. I haven't tried Glide yet, but considering Google also recommends Volley for networking, which has barely any docs and some really strange bugs, I'm not sure how much I'd trust that recommendation.


I haven't tried this Kotlin library yet, but it offers an easy way to add theming to your app, which I've never tried before. I'm keen to give this a go when I need to add theming options for an app in future.


I saw Anko mentioned all over the place for a while before I dug into what it is and why everyone loves it. Anko is basically a collection of convenience methods to make Android development in Kotlin easier and more succinct. It has some really great stuff, like this super-succinct method for creating and showing a toast:

toast("Hi there!")

And for a SnackBar:

longSnackbar(view, "Wow, such duration")

It also makes creating intents a lot more simple, for example:

startActivity<SomeOtherActivity>("id" to 5)

And there are built-in convenience methods for common intents, like browse(url) and share(text, [subject]).

I haven't tried it yet, but Anko also offers a nice-looking DSL for creating layouts. Here's an example from the docs:

verticalLayout {
    val name = editText()
    button("Say Hello") {
        onClick { toast("Hello, ${name.text}!") }

There's lots of other stuff, too, so Anko is definitely worth a look.


After dealing with the weird bugs and lack of docs for Volley, I stumbled across Fuel, which is now my favourite networking library for Android. Fuel uses lambdas for handling responses, rather than requiring listeners. Coming from iOS, this feels more familiar to me. It also works great with Kovenant, if you want to wrap your networking in promises, which I always do.


I haven't needed to use a library for JSON parsing yet, but I'm planning on trying Forge when I do. It's written by the same developer who's behind Fuel, and seems nice and simple to use.


I'm a bit late to the party with Result types, but I've just started exploring them in iOS, so I'm happy to have found this library for Result types in Kotlin. The README for this project offers a nice example of how Result types can be used to improve our code, too.