ArticleslgStudy

computer science

Android Runtime

Android Runtime is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Android Runtime rather than just read about it. In short: Android Runtime (ART) is an application runtime environment used by the Android operating system. Replacing Dalvik, the process virtual machine originally used by Android, ART performs the translation of some of the application's bytecode into native instructions that are later executed by the device's runtime environment.

Android Runtime — main illustration
Android Runtime — illustration

Key takeaways

  • Android Runtime belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Android Runtime to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Android Runtime from memory before moving on to harder problems.

Reference excerpt

Android Runtime (ART) is an application runtime environment used by the Android operating system. Replacing Dalvik, the process virtual machine originally used by Android, ART performs the translation of some of the application's bytecode into native instructions that are later executed by the device's runtime environment.

Overview

Android 2.2 "Froyo" brought trace-based just-in-time (JIT) compilation into Dalvik, optimizing the execution of applications by continually profiling applications each time they run and dynamically compiling frequently executed short segments of their bytecode into native machine code. While Dalvik interprets the rest of an application's bytecode, native execution of those short bytecode segments, called "traces", provides significant performance improvements. Unlike Dalvik, ART introduces the use of ahead-of-time (AOT) compilation by compiling the most performance-critical parts of applications (previously, the entire app) into native machine code upon their installation. This way, ART improves the overall execution efficiency and reduces power consumption, which results in improved battery autonomy on mobile devices. At the same time, ART brings faster execution of applications, improved memory allocation and garbage collection (GC) mechanisms, new applications debugging features, and more accurate high-level profiling of applications. To maintain backward compatibility, ART uses the same input bytecode as Dalvik, supplied through standard .dex files as part of APK files, while the .odex files are replaced with Executable and Linkable Format (ELF) executables. Once an application is compiled by using ART's on-device dex2oat utility, it is run from the compiled ELF executable; as a result, ART eliminates various application execution overheads associated with Dalvik's interpretation and trace-based JIT compilation. Initially, a disadvantage of ART was that additional time was required for compilation when an application was installed, and applications took up slightly more secondary storage (usually flash memory) to store the compiled code. Long AOT compilation became especially problematic when monthly security updates became the norm, locking users out of the OS for a long time after each update. To improve on this, a hybrid approach was introduced in Android 7.0 (Nougat). Newly installed apps run using JIT compilation, and get profiled by the runtime. When the device is idle and charging, the runtime performs AOT compilation on the most frequently used ("hot") code.

History Android 4.4 "KitKat" introduced a technology preview of ART as an alternative runtime environment to Dalvik, which remained the default virtual machine. In the subsequent major Android release, Android 5.0 "Lollipop", Dalvik was entirely replaced by ART. Android 7.0 "Nougat" turned the ART from a pure AOT to a hybrid JIT/AOT solution, while switching its Java Runtime Environment from the discontinued Apache Harmony to OpenJDK, introducing a JIT compiler with code profiling. The JIT compiler complements ART's AOT compiler, helping to improve runtime performance and save storage space by identifying "hot code" (code which is frequently used, runs on the UI thread or affects startup time), which the AOT compiler compiles to machine code while the device is idle and charging. Less-frequently used code relies on JIT compilation. Android 9 "Pie" reduced the amount of storage used by APKs by using compressed bytecode files, and profiler data can be uploaded to Google Play servers to be bundled with apps when downloaded by users with a similar device, which shortens download time from Google Play by up to 40%. Google Play cloud profiles allow apps to be optimized on installation, which helps avoid the initial performance issues present on Android 7.0 to 8.1. In July 2021, the concept of baseline profiles was introduced. Baseline profiles are ART profiles that define methods and classes which should undergo AOT compilation from an app's first launch, and are compatible with Android 7.0 and later. They provide similar functionality to Android 9's Google Play cloud profiles when they are not available and automatically merge with cloud profiles when they are available. Baseline profiles are included with releases of AndroidX libraries and Jetpack Compose. ART was updated with a new garbage collector (GC) utilizing the Linux userfaultfd system call in Android 13. It reduces memory pressure, compiled code size and jank, and prevents the risk of killing apps because of low memory during garbage collection. Other changes also improve app startup, reduce jank and improve performance. Because of the Mainline project, Android 12's ART will also be updated.

See also

Android software development – various concepts and software development utilities used for the creation of Android applications Android version history – a history and descriptions of Android releases, listed primarily by their official API levels Comparison of application virtualization software – various portable and scripting language virtual machines Virtual machine – an emulation of a particular computer system, with different degrees of implemented functionality

References

External links

Official website Android Basics 101: Understanding ART, the Android Runtime on YouTube, XDA Developers, February 12, 2014 ART: Android's Runtime Evolved on YouTube, Google I/O 2014, by Anwar Ghuloum, Brian Carlstrom and Ian Rogers A JIT Compiler for Android's Dalvik VM on YouTube, Google I/O 2010, by Ben Cheng and Bill Buzbee Delivering Highly Optimized Android Runtime (ART) and Web Runtime on Intel Architecture, Intel, August 4, 2015, by Haitao Feng and Jonathan Ding Android 7.1 for Developers: Profile-guided JIT/AOT compilation, Android Developers, describes ART changes in Android 7.1

Worked examples

Example 1 — a first encounter with Android Runtime

Start with the simplest possible case. Write down what Android Runtime claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Android Runtime before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Android Runtime ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Android Runtime

In research
Android Runtime appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Android Runtime in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Android Runtime is common in secondary-school and first-year university syllabi. It links to neighbouring topics Android (operating system), Java virtual machine, Software using the Apache license, so understanding it makes those chapters shorter.
In everyday life
Look for Android Runtime outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Android Runtime” →

How to study Android Runtime in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Android Runtime means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Android Runtime out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Android Runtime in simple terms?

Android Runtime (ART) is an application runtime environment used by the Android operating system. Replacing Dalvik, the process virtual machine originally used by Android, ART performs the translation of some of the application's bytecode into native instructions that are later executed by the devi…

Why does Android Runtime matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Android Runtime?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Android Runtime.

Tags

  • Android (operating system)
  • Java virtual machine
  • Software using the Apache license

Keep exploring