Jake Wharton walks through shrinking a Kotlin JVM binary from ~1.62MiB to ~13KiB (99.2% reduction) for a dependency-tree-diff tool. The process involves: removing unused metadata files (.kotlin_module, .kotlin_metadata, maven files) for an 11% reduction, running R8 with ProGuard config to strip unused code for a 98% reduction, then manually replacing Kotlin stdlib file-reading and line-splitting APIs with Java NIO equivalents to eliminate transitive dependencies. The post also identifies remaining size contributors — Kotlin's multiplatform empty collection implementations and redundant null-check intrinsics — and recommends R8/ProGuard or GraalVM native image for anyone building JVM binaries.
Table of contents
Shrinking the binary2 Impressions