Individual Author Rahul Ravikumar Jan 26, 2026

Kotlin Intrinsics on Android

Article Summary

Rahul Ravikumar reveals how Android's tooling has been quietly carrying the weight of Kotlin's type safety. Every null check, every parameter validation adds overhead that pure Kotlin apps don't actually need.

When Kotlin compiles to JVM bytecode, it sprinkles Intrinsics checks everywhere to provide helpful error messages for Java callers. But if your entire app is Kotlin, these checks are pure overhead, bloating your dex file with unnecessary strings and method calls.

Key Takeaways

Critical Insight

Android Gradle Plugin 9.0 eliminates Kotlin's null-safety overhead automatically, giving you type safety at compile time and better runtime performance without any developer intervention.

The article includes a compiler explorer toggle showing the exact bytecode transformation and an even more aggressive optimization flag for pure Kotlin apps.

About This Article

Problem

Kotlin's null-safety checks add JVM bytecode that includes Intrinsics.checkNotNullParameter() calls with string constants. This creates extra overhead in the dex file when both the library and application use Kotlin.

Solution

R8 starting with Android Gradle Plugin 9.0 automatically replaces Intrinsics.checkNotNullParameter() invocations with invoke-virtual getClass() calls. ART can then compile these to efficient assembly code.

Impact

The PokedexScrollBenchmark benchmark showed better frame durations after this optimization. Compose can now produce frames with lower latency, and string constants no longer take up space in the dex pool.