Converting an android project to kotlin
This is a small write-up of my experiences from converting a native android-app from java to kotlin.
Convert your project!
The first step is easy, android-studio will do most of the work for you. To convert the existing java code into kotlin, simply select the src/main/java folder in the project and choose Code->“Convert Java File to Kotlin File”. Android studio will then try as best as it can to convert all your java-code to kotlin-code.
Android studio will convert all your .java files into .kt files in-place, leaving them in src/main/java.
Your project will probably not compile now, because of differences in how java and kotlin handle #nullability.
nullability(.!!?) issues
One of the big advantages kotlin has over java is the handling of nullability. By default, an object is non-nullable and has to explicitly specified to be nullable.
Android-annotations (if applicable)
To use android-annotations, add the kotlin-kapt plugin to your build-script and add the android-annotations-dependency to the kapt-configuration:
...
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
...
dependencies{
...
kapt "org.androidannotations:androidannotations:4.3.1"
}