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.