r/androiddev • • 11h ago

Video Tracing 15 years of Android Dynamic Code Loading

https://www.youtube.com/watch?v=4rogmPQPYI4&feature=youtu.be

Recently I was talking to an early-career engineer about Dynamic Code Loading on Android, and a tenured engineer who overheard us was surprised to learn something like that even existed. It made me realize how much of Android's history around runtime patching and hot reload has faded into folklore, so I went down a rabbit hole this thanksgiving weekend tracing the full 15-year timeline since I have experienced a lot of this personally very early on in my career.

Ever so grateful to two engineers who I got to learn a lot from early on in my career Jorge Alvarez & Alexey Kuznetsnov who did a lot of work with DCL at Booking.

Putting it all in one place made a few patterns stand out:

  1. The 2011 catalyst: Google published "Custom Class Loading in Dalvik" on the Android Developers Blog to help apps work around the 64K method limit using DexClassLoader. It wasn't built for hot reload, but it opened the door to loading DEX bytecode dynamically at runtime.
  2. JRebel & Instant Run (2015): ZeroTurnaround proved Android devs would pay out of pocket for JVM-style hot swapping. Google responded at Android Dev Summit 2015 with Instant Run (upfront bytecode instrumentation + Hot/Warm/Cold swaps). Even during Dave Burke's live keynote demo, it broke and forced an uninstall—and by Google I/O '19, Google deleted ~50k lines of Instant Run code and replaced it with Apply Changes, relying on Android 8+ platform APIs instead of rewriting bytecode upfront.
  3. Production hot-patching in China: Because Google Play isn't available in China and apps had to ship across dozens of fragmented OEM stores, teams at Alibaba (AndFix/Sophix), Tencent (Tinker), and Meituan (Robust) took classloader swapping and bytecode instrumentation into production to patch live crashes during events like Singles' Day without waiting days for store reviews.
  4. The crackdown: Once teams moved past emergency crash fixes and started shipping silent feature updates, Google Play updated its Device and Network Abuse policy to ban downloading executable code (.dex, .jar, .so) outside Play, Apple enforced Guideline 2.5.2 against JSPatch on iOS, and China's MIIT tightened app filing rules.
  5. Where we are now: Production hot-patching is locked down on Play, while dev-time hot reload is finally maturing via Compose Live Edit and JetBrains' Compose Hot Reload (using JetBrains Runtime / DCEVM class redefinition).

For anyone who was around during the Eclipse / Android Studio 2.0 days: did you/your company ever use DexClassLoader hacks during build time or production?

*Full disclosure: after that conversation, I figured others might enjoy learning about this too, so I put the research and original ADS 2015 / I/O '19 / KotlinConf clips into a YouTube video

3 Upvotes

2 comments sorted by

2

u/SnipesySpecial 9h ago

hear me out. we take the jvm, shuffle some bytecode around, make it run on android, and we hot reload that.

1

u/droidchef 9h ago

Yeah we can’t have nice things in life as Android devs.