Android developers need at least a basic understanding of the architecture of the operating system and the rest of the platform. Android is designed around a kernel built around Linux. It's a version of Linux that's highly optimized for mobile operating systems. It's as small as possible so that it works on devices that have constrained CPU and memory capabilities. On top of the kernel is the Android Runtime, and a set of libraries that enable the operating system’s behaviors.
- [Instructor] Android developers need at least a basic understanding of the architecture of the operating system and the rest of the platform. Android is designed around a kernel that's built around Linux. It's a version of Linux that's highly optimized for mobile operating systems made as small as possible so that it works well on devices that have constrained CPU and memory capabilities. On top of the kernel is the Android runtime, and a set of libraries that enable the operating system's behaviors. The next level up is the application framework, which sits on top of the Android runtime and the associated libraries.
And then finally at the top are the apps themselves, including those that are included with the operating system and those the user installs. Let's break down each of these layers. The Linux kernel, again, starts with Linux itself, but then it also has a set of drivers, and these drivers are tuned to the particular hardware that the operating system is running on. There are drivers for audio, camera, display, the keypad, flash memory management, power, Wi-Fi, and so on.
It's up to the OEMs, that is the manufacturers of the devices, to customize these drivers and make them work for their own devices. So if you're holding an Android device in your hand, the version of Android that's on that device will be a combination of what Google delivers and what the vendor customizes. This is even true of the Nexus and Pixel devices, because they're all manufactured by specific vendors, Asus, LG, Motorola, HTC, and so on.
The next layer is the Android runtime. This includes a collection of core libraries, and critically, the virtual machine. Android 4.4 and prior versions used a virtual machine named Dalvik. In Android 5, Dalvik was replaced by a new virtual machine simply named ART, for Android runtime. ART was introduced experimentally in KitKat, and completely replaced Dalvik in Lollipop. ART uses ahead-of-time compilation instead of the just-in-time model used in Dalvik.
This means that apps are compiled into machine code upon installation or, in Android 7, the first time you open the app, rather than waiting until features are used for the first time. As a result, apps run a bit faster under ART, all other things being equal. ART also has improved garbage collection, so you see fewer pauses and stutters in low memory conditions. And there are other improvements you can learn about in the documentation. To compile an Android app, you use the compiler that's included with the Android SDK.
And as I mentioned previously, there are now two compiler chains, the Legacy compiler and the Jack compiler that's been introduced in Android 7. The compiler looks at your own code and also works with a bunch of libraries that are provided within the Android SDK. These libraries manage all sorts of features, including graphics, databases, encryption, typefaces, and so on. They work at the same level of the software stack as the core runtime, but they're expandable, and so device makers can add their own libraries to this layer.
Next is the application framework. It has modules for controlling all of the different components of your apps. This includes activities, which represents the screens that the user sees, and content providers to manage data and move that data between apps, locations, notifications, windows resources, telephone management and so on. And finally there are the apps. Each version of Android as packaged by Google has been delivered with an expanded set of default apps. But if you get a device that doesn't have Google licensing, such as say an Amazon Fire tablet, it'll have a different set of default applications.
If a device is licensed to use Google services, it'll have Gmail, Hangouts, Google Maps, and so on. Devices that use customized versions of Android, such as Amazon's Kindle Fire lineup, will have their own versions of these apps. But at minimum, every version of Android has a home, or launcher, screen, a browser, contact and calendar management, and phone and camera management. More and more standard apps are included with each new version of the operating system, but you can add as many apps to this layer as you want.
Once again, including both those apps that you get from the store and also apps that you as a developer build for yourself. As a developer, you'll be putting together your apps using components from the Android SDK. There are some major types of components to know about, but every single component is implemented in the SDK as a Java class. For example, an activity is an instance of a class named Activity or one of its subclasses, and a button is an instance of a class named Button.
Each of these classes is a member of a particular package, and the more you know about the structure of the SDK and where the different classes are packaged, the more effective you can be as a developer. So activities represent the user interface screens, and buttons, text views, edit text, and other widgets are all known as views. You arrange those views on the screen using something called a view group, and basically the activities, the views, and the view groups are the major building blocks of your user interface.
There are other kinds of components though in Android that are equally important, but the user doesn't see. Services perform background tasks, and there are a couple of different kinds of services you can use. Broadcast receivers can react to messages, and you can also create your own broadcasters to send messages within your application. Content providers provide managed access to data. In this course, we'll be focusing on the user interface. I'll be talking about activities, views, and view groups primarily, and in later courses in this series, I'll talk about some of these other components, which can be absolutely vital in creating real production applications.
Not every app will use all these platform elements. The simplest business apps might use data storage and simple input and output, while more complex apps might incorporate background services, content providers, media players, and more. It's up to you as the developer to decide what your app needs and which elements of the platform you need to use.
- Installing Android Studio
- Creating your first Android Studio project
- Managing profile files, including Gradle scripts and support libraries
- Defining screens with activities
- Implementing designs in XML layouts