Integrating Kotlin into existing Android applications

OData support
Dr. Forstner Bertalan
Department of Automation and Applied Informatics

Android application development has many difficulties that are well known for all developers. Some of the problems are considered given setbacks (limited hardware performance, various screen sizes), while other problems’ solution depends on the capabilities of the programming language (parallel computing, memory management). Using the right programming language could not only minimize the number of bugs, but also increase developer productivity.

The thesis examines the link between Java, which used to be the only language used in native Android development, and a relatively new language, Kotlin; furthermore, the benefits and drawbacks of the latter. The study is based on three projects written in Java, which have been gradually re-written in Kotlin.

First, the new features of recent Java releases are discussed, as well as their support, or the lack thereof on the Android platform. Then, the Kotlin language is presented, which compiles to the Java Virtual Machine’s bytecode; thus, making it an ideal choice for Android development. Kotlin promises increased developer productivity, as well as cleaner, more secure code by using modern language features. The analysis of these claims is based on various programming aspects and software metrics, for instance lines of code, compile time, and code complexity.

By gradually re-writing these projects in Kotlin it was possible to examine the promises of the new language, as well as compare the re-written Kotlin codebase to the original Java-based one. The new language elements indeed result in shorter and cleaner code; the lines of code decreased by 7-21% per project. What is more, the two languages can interoperate in the same project, however, the developer must keep in mind the exact rules of this interoperability. After the Kotlin re-write, the final application size only increased by 54KB, moreover, the method count only increased by the equivalent of a medium-size dependency. Unfortunately, compile time increased by 30-60% per project, depending on the amount of re-written code and other factors. However, recent releases of the Kotlin compiler show gradual improvement in compile time.


Please sign in to download the files of this thesis.