Android & Jetpack Compose (50 Qs)•Part 2: Compose Internals, Persistence, DI & Background Work (11 - 24)
What is the ART (Android Runtime) and how does AOT and JIT Compilation work?
senior LevelDocker & Containers
In Simple Words:
ART executes Dalvik bytecode (.dex files) on modern Android devices:
- Dalvik (Ancient): Pure JIT (Just-In-Time) compilation on every app launch; slow and battery intensive.
- Android 5.0 (Pure AOT): Ahead-Of-Time compilation during app install. Fast launches, but app installs took 10 minutes and consumed gigabytes of storage!
- Android 7.0+ (Profile-Guided Hybrid Compilation): Combines JIT, AOT, and Cloud Profiles.
- Apps launch with fast JIT.
- ART profiles hot code methods and compiles them to AOT machine code when the device is idle and charging.
- Baseline Profiles: Developers ship pre-compiled profiles with their AAB, delivering up to 40% faster initial app launch time!