64 CHAPTER 3: An Introduction to the Android Application Development Platform
This DEX format essentially amounts to being a compact, low-level executable file format that
the Android operating system, and therefore Android devices that run Android OS, will be able
to understand and run. A DEX is not specifically encrypted, but if you look at the contents of one
of these compiled files, it would not be decipherable! So the flow of code to bytecode to binary
(executable) data would be as follows:
XML (.XML) ➤ Java (.JAVA) ➤ ByteCode (.DEX) ➤ App (.APK) ➤ Runtime (DVM) ➤ Screen
The Android runtime environments (before Android 4.4, DVM was the only runtime; in 4.4, you can
choose between DVM and ART, and Android 5.0 and later use only ART), which we’re going to look
at in detail in the next section of this chapter, provide your apps with a core set of operating system
libraries. An app can access these via Java code and XML markup. These runtimes give your apps
access to hardware device features, as well as the low-level Android operating system functions, so
that you don’t have to do all of that low-level programming yourself!
You simply include the appropriate components from the libraries you need in your program, using
something in Java called an import statement. After you do this, your app’s code can employ that
built-in Java library’s capabilities. You will learn how to put a number of these powerful Java libraries to
work later on in this chapter, and in all the chapters, for that matter, during the remainder of the book.
Android Runtimes: Dalvik VM
To execute Java code at runtime, Android OS has always used a runtime engine called the Dalvik VM
(or DVM). The DVM was created specifically for use with Android OS, and is an optimization
mechanism and technology that allows an application’s Java code, XML mark-up, and new media
asset resources to be aggressively optimized so that it can be utilized within a low-power, mobile,
single-processor, and similar embedded environment.
An embedded environment is one in which a low-power computer (one that can run using a
battery) is actually “embedded” inside of a consumer electronics product. This is commonplace in
smartphones, smartwatches, smartglasses, tablets, eBook readers, iTV sets, and iDVD players, to
name a few.
I have also seen “smart” household appliances, such as refrigerators, ovens, and door locks that
feature embedded devices that utilize Android coming out this year. Thus, Android app development
is no longer limited to Internet 2.0 (wearable, portable, or mobile) devices anymore.
Note I am writing a title on how to develop Android applications for these Android appliances that is called:
Pro Android Appliances, which will be released sometime during 2015, as well as a new title on how to
develop Android applications for wearable devices, called Pro Android Wearables, so stay tuned!
The good news for Android app developers is that this DVM isn’t something that the developer
needs to worry about for their application development. I describe it here only to give you a sense of
what’s going on under the hood with Android to provide you with a comprehensive overview.