• 5,742,010
    REGISTERED
  • 47,198
    ONLINE NOW

The ART of Android

The ART of Android

Android 4.4 KitKat is indeed a sweet update. It brought dozens of new features, and its decreased memory footprint allowed it to be ported to older devices relatively easily. One of the most interesting features hidden deep inside developers options is ART, a new runtime compiler poised to replace our good friend Dalvik. What is ART and why should you be interested in it? Let’s dig deeper.

Android uses a virtual machine to execute code. It’s not a perfect solution. And because of this, Android devices need more resources to run smoothly than for example Windows Phone. Dalvik, which is the default runtime, is nothing more than the software that runs the applications on Android devices. Ever since Android 2.2, Dalvik has used a Just-In-Time compiler to interpret bytecode from Java language. Programs written in Java are then converted from a Java class files to a Dalvik Executable (.dex) before installation on a device. An odex is basically a pre-processed version of an application’s classes.dex that is execution-ready for Dalvik. When an application is odexed, the classes.dex is removed from the APK archive, and nothing is written to the Dalvik cache. An application that is not odexed ends up with 2 copies of the classes.dex file: the packaged file in the APK and the processed one in the Dalvik cache. It also takes a little longer to launch the first time since Dalvik has to extract and process the classes.dex file. And for reference, the name Dalvik comes from the name of the fishing village Dalvík in Eyjafjörður, Iceland, where the ancestors of Dan Bornstein (the creator of Dalvik) lived.

Dalvik is still a great project, but the Android developers decided to swap it for a higher performance runtime compiler: ART. This new runtime uses Ahead-of-Time compilation, where the bytecode is precompiled into machine language at the time of installation. That explains why applications installed with ART enabled take longer to install and less time to open. They also require more space, but this shouldn’t be a problem as almost all new devices have tons of internal storage. ART was introduced as an experimental feature in Android 4.4.In its current form, ART is not unequivocally faster than Dalvik in all benchmarks. However, we need to keep in mind that this runtime is still very new and optimization will take time.

According to newest commits in master branch of Android, ART will replace Dalvik in the next version of Android. Dalvik will still be available as an alternative runtime virtual machine to keep compatibility with certain older applications. You might have noticed that some applications like WhatsApp had some issues when Android 4.4 was released, especially for those running ART. However, these were mostly solved quite quickly, and now most apps works flawlessly on ART. This runtime compiler is definitely worth trying, but it is important to keep in mind a few potential cons like bigger apps and some problems with certain applications. That said, it’s a great feature that will only be tweaked further in upcoming releases.

You can read more about ART in an informational thread created by XDA Senior Member PradeepMurugan, who gathered together quite a bit of information and put it all in one place where most of highlighted issues are already covered. The next version of Android will be something big, and hopefully ART will be optimized enough to leave the Dalvik in the dust.

[Thanks to Nathan Strong from Stackoverflow for providing a complete definition of ODEX]

_________
Join us for xda:devcon 2014. For a limited time, XDA Portal readers get 20% off registration!
Advertisment
Advertisement

XDA TV: Most Recent Video

Buy/Sell on Swappa

  • Nexus 5 (Unlocked) buy | sell
  • Galaxy Note 3 (T-Mobile) buy | sell
  • HTC One M7 (Verizon) buy | sell
  • Galaxy S 5 (Unlocked) buy | sell
  • Nexus 7 2013 buy | sell
  • Swappa is the official marketplace of XDA