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.
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 http://www.methodscount.com/about
Here is snapshot of methods count from sample app https://github.com/googlesamples/android-NotificationChannels 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)
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.