The Android
operating system
Android is an
operating system based on the Linux kernel. The project responsible for
developing the Android system is called the Android Open Source Project (AOSP) and
is primarily lead by Google.
The Android system
supports background processing, provides a rich user interface library,
supports 2-D and 3-D graphics using the OpenGL-ES (short OpenGL) standard and
grants access to the file system as well as an embedded SQLite database.
An Android application
typically consists of different visual and non visual components and can reuse
components of other applications.
Task
In Android the reuse of
other application components is a concept known as task. An application can access
other Android components to achieve a task. For example, from a component of
your application you can trigger another component in the Android system, which
manages photos, even if this component is not part of your application. In this
component you select a photo and return to your application to use the selected
photo.
Such a flow of events
is depicted in the following graphic.
Flow of events
depicted in Android
Android
platform components
The Android system is a
full software stack, which is typically divided into the four areas as depicted
in the following graphic.
Description of
Android Development Layer
The levels can be described
as:
l Applications
- The Android Open Source Project contains several default application, like
the Browser, Camera, Gallery, Music, Phone and more.
l Application
framework - An API which allows high-level interactions with the Android system
from Android applications.
l Libraries
and runtime - The libraries for many common functions (e.g.: graphic rendering,
data storage, web browsing, etc.) of the Application Framework and the Dalvik
runtime, as well as the core Java libraries for running Android applications.
l Linux kernel
- Communication layer for the underlying hardware.
The Linux kernel, the
libraries and the runtime are encapsulated by the application framework. The
Android application developer typically works with the two layers on top to
create new Android applications.
Google Play
Google offers the Google Play
service, a marketplace in which programmers can offer their Android
applications to Android users. Customers use the Google Play application which
allows them to buy and install applications from the Google Play service.
Google Play also offers
an update service. If a programmer uploads a new version of his application to
Google Play, this service notifies existing users that an update is available
and allows them to install the update.
Google Play provides
access to services and libraries for Android application programmers, too. For
example, it provides a service to use and display Google Maps and another to
synchronize the application state between different Android installations. Providing
these services via Google Play has the advantage that they are available for
older Android releases and can be updated by Google without the need for an
update of the Android release on the phone.
Android
Development Tools
Android SDK
The Android Software
Development Kit (Android SDK) contains the necessary tools to
create, compile and package Android applications. Most of these tools are
command line based. The primary way to develop Android applications is based on
the Java programming language.
Android debug bridge (adb)
The Android SDK
contains the Android
debug bridge (adb), which is a tool that allows you to connect to a
virtual or real Android device, for the purpose of managing the device or
debugging your application.
Gradle and
the Android plug-in for Gradle
The Android tooling
uses Gradle as build system. The Android team provides a Gradle plug-in for
build Android applications which is entered in the build.gradle file in the top
root of the Android project. It typically looks like the following, please note
that the version might be different in your case.
Android
Developer Tools and Android Studio
Google provides an IDE
called Android
Studio as the preferred development environment for creating
Android applications. This IDE is based on the IntelliJ IDE.
The Android tools
provide specialized editors for Android specific files. Most of Android's
configuration files are based on XML. In this case these editors allow you to
switch between the XML representation of the file and a structured user
interface for entering the data.
This description uses
Android Studio as IDE.
Android
RunTime (ART)
Android 5.0 uses the Android RunTime
(ART) as runtime for all Android applications.
ART uses Ahead Of Time
compilation. During the deployment process of an application on an Android
device, the application code is translated into machine code. This results in
approx. 30% larger compile code, but allows faster execution from the beginning
of the application.
This also saves battery
life, as the compilation is only done once, during the first start of the
application.
The dex2oat
tool takes the .dex file created by the Android tool change and compiles that
into an Executable and Linkable Format (ELF file). This file contains the dex
code, compiled native code and meta-data. Keeping the .dex code allows that
existing tools still work.
The garbage collection
in ART has been optimized to reduce times in which the application freezes.
How to
develop Android applications
Android applications
are primarily written in the Java programming language.
During development the
developer creates the Android specific configuration files and writes the
application logic in the Java programming language.
The Android tooling
converts these application files, transparently to the user, into an Android
application. When developers trigger the deployment in their IDE, the whole
Android application is compiled, packaged, deployed and started.
Conversion
process from source code to Android application
The Java source files
are converted to Java class files by the Java compiler.
The Android SDK
contains a tool called dx which converts Java class files into a .dex
(Dalvik Executable) file. All class files of the application are placed in this
.dex
file. During this conversion process redundant information in the class files
are optimized in the .dex
file.
For example, if the
same String
is found in different class files, the .dex file contains
only one reference of this String.
These .dex
files are therefore much smaller in size than the corresponding class files.
The .dex
file and the resources of an Android project, e.g., the images and XML files,
are packed into an .apk
(Android Package) file. The program aapt (Android Asset Packaging Tool)
performs this step.
The
resulting .apk
file contains all necessary data to run the Android application and can be
deployed to an Android device via the adb tool.
No comments:
Post a Comment