DEV Community

Cover image for How to Achieve Instant Android Hot Reload
Elimihele God's favour
Elimihele God's favour

Posted on

How to Achieve Instant Android Hot Reload

Android development is plagued by long feedback loops. If you make a tweak to a padding value, an alignment, or a color, Gradle will make you wait. Sometimes seconds, sometimes minutes. This single bottleneck ruins the developer "flow state."

We wanted a web-like developer experience on physical Android devices. We wanted an instant UI hot reload. Here is how we achieved it in JetStart.

The Architecture of Speed

Standard Android development compiles your whole app, signs an APK, and pushes it via ADB. This is fundamentally slow. JetStart circumvents this process entirely during development.

Here is the step-by-step pipeline we use:

  1. File System Watching: A Chokidar process watches your project directory. As soon as a .kt file changes, we grab it.
  2. Targeted Compilation: We do not run Gradle. We invoke kotlinc directly, passing only the changed file and compiling it into Java classes using the Compose compiler plugin.
  3. Instant Run Hooks: Our OverrideGenerator injects standard $Override companion logic into the class so the Android runtime natively swaps the implementation.
  4. DEX Translation: We pipe those .class files into Google's d8 tool, spitting out a raw .dex payload.
  5. WebSocket Delivery: ADB is too slow, so we rely on WebSockets. The DEX is base64-encoded and blasted to your device over a local Wi-Fi or USB connection on port 8766.
  6. Live Execution: The JetStart client app running on your device intercepts the DEX payload, feeds it to a custom ClassLoader, and forces an instant recomposition of your UI.

Top comments (0)