We might think that as android is written in java it should also run on Java Virtual Machine using Java Compiler to compile its code. However, this is different in android ie. android uses Dalvik Virtual Machine to execute its code.
Dalvik Virtual Machine was build to make applications run in environment with resource constrains. By resource constrains what do we mean here is, comparatively mobile devices run under particularly low memory while desktop devices or laptops are high end devices with lesser constrains like this. Hence, Dalvik VM was specially designed to run on resource-constrained environment.
Extra Info: Dalvik byte codes are a similar representation to java byte codes but they provide android to run its application on its own VM which are free from Oracle licensing clutches.
What happens behind the scene when we compile our code.
So basically the java compiles the Java source file into multiple Java bytecodes. Next, a tool called DX transforms the Java bytecodes into a single file of a different bytecode format called DEX, and this bytecode file is usually called classes.dex. The DEX file is packaged with
other application resources and installed on the device. And finally when the user launches the application, the Dalvik Virtual Machine will
then execute the classes.dex file.
Android Runtime (ART)
After kitkat there is an option to run the app in either DVM or ART. Basically what DVM does is it compiles the code at runtime ie. everytime we launch an app the just-in-time compiler compiles the app to run in DVM. However in ART the code is compiled to native code ie. it will only take time to execute at first launch but on every app launch later is much faster than DVM.