Expo SDK 56 introduces a Kotlin compiler plugin that eliminates runtime reflection from Expo Modules on Android. A new Kotlin compiler plugin in SDK 56 strips reflection from Expo Modules on Android: 70% faster init, no code changes for app developers. By Łukasz Kosmaty.

Expo replaced the expensive runtime reflection used to discover type metadata in Android modules with a Kotlin compiler plugin. Instead of asking the JVM about types and object shapes at startup, the compiler pre-computes that information during build and bakes it directly into the bytecode.

The plugin operates on Kotlin’s intermediate representation (IR) during compilation. It targets two reflection-heavy operations:

  1. Type resolution — calls like typeDescriptorOf<T>() are replaced at compile time with pre-built, cached type descriptors. No runtime reflection needed.
  2. Record conversion — classes marked with @OptimizedRecord have their property names, types, and accessors compiled into direct bytecode instructions. The runtime skips reflection entirely and falls back gracefully if the annotation is absent.

Measured on a module-heavy test app across a OnePlus 9 Pro and a Samsung Galaxy S9:

  • Module initialization: ~70% faster
  • Time to first render: ~30% faster
  • Record conversion: *~6x faster

The approach leverages Kotlin 2.0’s K2 compiler plugin API, which allows modifying code during compilation rather than generating parallel files. Good read!

[Read More]

Tags software-architecture kotlin app-development android performance