Which kind of code in the process of android platfrom, Dalvik byte-codes or native machine code?

452 views Asked by At

I'm not quite sure which kind of code is loaded into the linux process on android platform.

If android adopts Dalvik, the process contains a Dalvik VM and the code of the application, is the code in the form of Dalvik byte-codes? If yes, is the code the same as the classes.dex in the .apk file?

If android adopts Android Runtime (ART), as the classes.dex has been translated into native machine code, so I think the app's code in the Linux process will not be the Dalvik byte-codes, but the native machine code. If my understanding is right, then is the Dalvik VM still contained in the process?

1

There are 1 answers

0
Vince On BEST ANSWER

As of Android 5.0(Lollipop), Dalvik has been entirely replaced with Android Runtime(ART), which processes native binaries.

Verifying App Behavior on the Android Runtime

The Android runtime (ART) is the default runtime for devices running Android 5.0 (API level 21) and higher.


At install time, ART compiles apps using the on-device dex2oat tool. This utility accepts DEX files as input and generates a compiled app executable for the target device

To be more specific, Dalvik promotes the use of odex files, which were pre-processed optimized versions of the dex files for Dalvik to either interpret or JIT compile.

ART promotes the use of ELF files, which are is a generic format that guides the linking of certain functions and objects to the native instructions for your device, performed on install.

Wikipedia - Android Runtime

Unlike Dalvik, ART introduces the use of ahead-of-time (AOT) compilation by compiling entire applications into native machine code upon their installation.


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 solely from the compiled ELF executable

Executable and Linkable Format - Applications

Android uses ELF .so (shared object) libraries for the Java Native Interface. With Android Runtime (ART), the default since Android 5.0 "Lollipop", all applications are compiled into native ELF binaries on installation

ART does not contain an instance of Dalvik, and although mostly compatable, it's mentioned that some features supported by Dalvik aren't supported by ART.

Verifying App Behavior on the Android Runtime

However, some techniques that work on Dalvik do not work on ART. This document lets you know about things to watch for when migrating an existing app to be compatible with ART. Most apps should just work when running with ART.