Impact on Android dex limit when using Kotlin

I’ve been following Kotlin for a while, and after Google I/O 17 announcement it became the officially supported language for Android.

Naturally the interest also spiked after the announcement.

I was curious to know how much does it cost to use Kotlin in Android, but wasn’t able to find a quick answer after googling (may be I didn’t search enough ¯\_(ツ)_/¯). So, wanted to check myself using tools described in

APK with Kotlin — Method Count

Here is snapshot of methods count from sample app comparing Kotlin VS non-Kotlin APK (both APK was built using ./gradlew assembleDebug from it’s respective project root).

* Kotlin App Method Count: 24,218 (using version 1.1.2–4)
 * Non-Kotlin App Method Count: 18,047
 * Method Count Difference: 6,171 (Library Methods: 5748)

APK without Kotlin — Method Count

So, around 6K method count for using fun & amazing language Kotlin is insignificant compared to support library and google play services which combined can easily be over 20K methods.

By using ProGuard we can also greatly reduce the number of method count.

Kotlin Method Count by Package

Here are some interesting observation from method count graph — It seems they have heavily invested in collections framework to make it better, and the next big chunk is taken by text/string related classes.

P.S. Feel free to correct me if you find any wrong or misleading information.