Add your SDK
Home / Kotlin
Enjoy the best mobile SDKs news, tips & tricks, sent to you by mail

Hello, Kotlin! Converting an Android Project – Part 2

January 24, 2017 10:37 AM

I was trying to convert an Android project to Kotlin in Android Studio via the Kotlin plugin. If you haven’t read part one (you can always do it now), then I’ll briefly tell you that it’s up to you to choose how many classes to convert. I chose them all. The conversion caused numerous compilation errors and practically swayed me to convert one/two classes at a time. Even though solving compilation errors was a great way to learn, I still had an ambition – convert my MVP example project from Java to Kotlin code.

Therefore, I decided to attack it from another angle. My second approach was less messy – one or two compilation errors per conversion, albeit it took me a couple of hours to get everything working.

In the following post I will cover:

  • Adapter’s getView() runtime error, caused by the conversion
  • Kotlin pros/cons for Android developers
  • Verbosity comparison of Java vs Kotlin

TL;DR Conversion might cause errors but Kotlin will reduce NullPointerExceptions, and minify your code into a much more readable version.

Continue Reading

Hello, Kotlin! How to Convert an Android Project – Part 1

January 17, 2017 5:13 PM

I’ve been hearing about Kotlin everywhere. It’s the new big thing in the Android world. So big that Gradle themselves are talking about incorporating it.

So I set out on a journey to see what the hype is all about.

What is Kotlin? Well, simply put it’s a statically-typed language from the house of JetBrains that compiles to Java’s bytecode and therefore can be run using a JVM. It’s got lots of interesting features and full compatibility with Java.

The following post is not a conventional Hello World tutorial on Kotlin, rather it’s an experiment with a big bold “don’t try this at home” warning. It’s risky and code might break because I’m going to convert a whole project of a mid-level complexity (30 classes) at the click of a button, or rather 4 buttons (ctrl + alt + shift + k). If that won’t work out (spoiler alert: it didn’t), I’ll switch to plan B and convert my project one class at a time.  I’ve decided to see if they’re making good on their promise, as well as teaching myself a new programming language upside down. From big concepts to the finer details.

Because I’m going to mess with lots of code and it might not end up pretty I chose to convert one of Android’s google-samples projects which I forked. I chose the todo-mvp branch: If you are unfamiliar with different styles of Android architecture (MVC, MVP, MVW) or their implications I highly recommend going over them anyway if you haven’t yet.

TL;DR: we’re converting a TODO List app.


IDE = Android Studio 2.1.2. There’s a plugin for Eclipse too.

Kotlin version = 1.0.4

The before photo (before tinkering):

Hello, Kotlin! How to Convert an Android Project – Part 1

Continue Reading