ART Runtime Interview Questions

ANDROID › System

What is ART, and how is it different from the old Dalvik runtime?

What a strong answer covers: ART (Android Runtime) replaced Dalvik in Android 5. Dalvik mostly interpreted and JIT-compiled bytecode at runtime. ART added ahead-of-time compilation to native code, a better garbage collector, and improved debugging. Since Android 7, ART uses a hybrid: interpretation and JIT at first, profiling hot code, then AOT compiling it while the device is idle and charging.

What is DEX, and how does your Kotlin code get from source to running on a device?

What a strong answer covers: Kotlin compiles to JVM bytecode (.class files), which D8 converts into DEX bytecode, designed for Android's register-based runtime, and R8 shrinks and optimises it in release builds. The DEX files go into the APK or AAB. On the device, ART interprets, JIT compiles, or AOT compiles that DEX into machine code depending on profiles.

What are Baseline Profiles, and why do they speed up startup?

What a strong answer covers: A Baseline Profile is a list of classes and methods used during startup and critical user journeys, shipped with the app. Play and ART use it to AOT compile that code at install time, so the first launches don't run interpreted or wait for the JIT. It typically improves cold start and early jank by around 20 to 30 percent. You generate them with the Macrobenchmark library.

How does garbage collection work in ART, and what causes GC-related jank?

What a strong answer covers: ART uses a concurrent, generational, mostly-moving collector (concurrent copying), so most collection happens alongside the app with short pauses. Jank comes from allocation churn: allocating many short-lived objects in hot paths like onDraw, onBindViewHolder or per-frame code triggers frequent GCs that compete for CPU and occasionally pause threads. Fix by avoiding allocation in hot loops and reusing objects.

What is the 64K method limit and multidex, and what is the relationship between R8, DEX layout and startup performance?

What a strong answer covers: One DEX file can reference at most 65,536 methods; beyond that you need multiple DEX files (multidex), native on API 21+. R8 removes unused code to cut method counts and size, and can optimise DEX layout so startup classes go in the primary DEX with startup profiles, reducing page faults when the app starts. Fewer classes loaded and less code to verify mean faster cold starts.

Back to ART Runtime