ART on Android L: Activate the new runtime and get the most out of your device

  • ART compiles AOT upon installation, reducing JIT load on runtime and improving fluidity.
  • For the user: increased performance and lower consumption; slower installation and a ≈20% increase in space.
  • On modern Android, ART is usually the default; the Select runtime option may not be present.
  • For developers: Review GC, JNI, bytecode verification, and environment detection.

Android L ART on your device

With Android L A new way to enjoy Google's operating system, Material Design, has arrived. However, the update is not just visual, but also will increase performance thanks to some features like ART, the new virtual machine to replace Dalvik and that you can now enjoy on your device.

Saving the technicalities, let's say the Dalvik environment only supports 32-bit applications, while the new virtual machine, ART, it is capable of running 64-bit applications. Although we are still waiting for the first smartphones with 64-bit processors to appear and become widespread, the truth is that already we can use this environment on our device to see how performance is increased in general of this one. 64-bit support opens the door to more memory and better optimizations in demanding apps.

Of course, to carry out these steps what we have to take into account is that only works with Android 4.4 KitKat or higher versions, so this method will only be suitable for the newest smartphones. For example, some we can use ART on are the Samsung Galaxy S5, the HTC One M8, the LG G3, and devices like the Nexus range or Motorola Moto. In modern versions of Android, ART is already enabled by default., so you may not see the option to switch environments. Now, what do we need to do to enjoy some of the benefits of Android L?

JIT vs AOT: What changes with ART and why it's noticeable

Android apps are distributed as APK with DEX bytecode, independent of the processor architecture. This bytecode must be translated into native machine code to execute. The key difference between Dalvik and ART is compilation time.: Dalvik uses just-in-time (JIT) compilation at runtime, while ART uses ahead-of-time (AOT) compilation when installing the app.

With Dalvik, every time you opened an app, the virtual machine compiled on the fly parts of the bytecode and cached it, consuming CPU usage in real time. With ART, the compilation happens when installing the application, leaving the native binary ready for your CPU. This reduces processor work peaks during use, improves the fluidity of the interface and contributes to a lower energy consumption.

dalvik-art

Impact on users: benefits and commitments

For those who use their mobile phone daily, ART translates into apps that open faster, smoother animations, and less stuttering when switching between tasks. By not spending cycles on hot compilation, The battery suffers less during long sessions of use and games.

  • Somewhat slower installation: When you install it, the system compiles the entire app for your processor. It usually takes seconds or tens of seconds.
  • More storage space: The native code takes up approximately an additional 20% in many cases compared to Dalvik.
  • Better sustained performance: more fluid use, especially in multitask and intensive apps.

These compromises seem reasonable: a little more time to install and a little more storage in exchange for greater speed and efficiency in everyday life. On mid-range and entry-level devices, ART can make a noticeable difference.

How to activate ART if your phone allows it

The first thing we will have to do is get to "Settings”And navigate to the end of this menu to select the option“About of the phone”. In this section you will see the "Build Number" or "Build Number”, Which we will have to press for 7 times consecutively to enable the developer options -a message will appear confirming it-. The second step will be to return to the Settings menu and find the new “Developer Options” option that has just appeared and where you can select the option “selectruntime".

At that time we will only have to select the ART button (by default Dalvik will be selected) and that's it, from that moment on we will use the new Android L virtual machine. As you can see, the procedure is very simple and with it you will be able to Increase performance from your device easily. Nota: In many current versions, this option no longer appears because ART is the default environment, so there is nothing to change.

Considerations for developers: compatibility and best practices

Most apps designed for Dalvik work on ART without changes, but it's worth checking a few points to make sure compatibility and performance optimal:

  • Environment detection: from your code, query System.getProperty("java.vm.version"). Yes it is 2.0.0 or higher, the app runs on ART.
  • Garbage collector: avoid invoking System.gc() manually. ART incorporates a More efficient GC and does not require explicit calls to mitigate GC_FOR_ALLOC.
  • Bytecode and tools: ART is stricter checking bytecode. Update obfuscators and post-processors to their compatible versions to avoid rejections.
  • JNI and Memory Safety: debug with CheckJNI. don't keep pointers to ArrayElements or objects moved by the GC to avoid memory corruption.
  • Reflection and base classes: do not inspect fields java.lang.Object; their fields are private. Stop the inspection when you reach that class.
  • Clearer errors: ART throws NoSuchFieldError y NoSuchMethodError instead of null, and makes it easier to track NullPointerException indicating the affected method.

Applying these guidelines reduces surprises in production and takes advantage of ART's internal improvements in verification, debugging and performance.

And as always, if you want learn more tricks for your Android, you just have to visit our dedicated section.

Via Phone ArenaThis runtime environment change was born as a simple way to speed up compilation and transform the experience: less latency, more stability and better use of hardware both on recent mobile phones and on models with limited resources.


Visible battery cycles in Android 14
It may interest you:
4 tricks to know the health of your battery