Chapter 2 Installation & Configuration
Chapter 2 Installation & Configuration
Android SDK is made up of two main parts: the tools and the packages. When you first install
the SDK, all you obtain are the base tools. These are executable and supporting files that help you
develop applications. The packages are the records specific to a particular version of Android (called
a platform) or a particular add-on to a platform.
• Use the AVD Manager to create an AVD. An Android Virtual Device (AVD) is used for testing
the Android applications. An AVD is an emulator occurrence that enables to form a real
device. Each AVD consists of a hardware sketch, a connection to a system image, and
emulated storage, such as a secure digital (SD) card.
An AVD consists of:
• A hardware profile: Defines the hardware features of the virtual device. For example, you
can describe whether the device has a camera, whether it uses a physical QWERTY keyboard
or a dialing pad, how much memory it have, and so on.
• A mapping to a system image: You can define what version of the Android platform will run
on the virtual machine. You will be able to choose a version of the standard Android
platform or the system image packaged with an SDK add-on.
• A dedicated storage area on your development machine: the device's user data (installed
applications. settings, and soon) and emulated SD card are stored in this area
• The API Level of the goal is important because our application will not be able to run on a
system image as specified in the minimum SDK Version attribute of the manifest file of that
application.
Q. Describe Emulators
Ans:
• The Android SDK comes with a virtual mobile device emulator that runs on your computer.
The emulator enables us trial product, to develop and test Android applications without
using a physical device.
• The Android emulator mimics all of the hardware and software features of typical mobile
devices, except that it cannot place actual phone calls. It provides a selection of navigation
and control keys. Which you can “press” using your mouse or keyboard to generate events
for our application. If provides a screen in which our application is displayed, together with
any other active Android applications.
• The Android emulator runs on a full Android system stack, down to the kernel level,
including a set of preinstalled applications (such as the dialer) that you can access from your
applications. We can select the version of the Android system we wish to run in the
emulator by configuring AVDs, and we can also modify the mobile device skin and key
mappings.
• While launching the emulator at the runtime, we can use a variety of commands and options
to control its behavior.
• The Android emulator offers dynamic binary translation of device machine code to the OS
and processor architecture of your development machine.
The android emulator supports many hardware features likely to be found on mobile devices,
including:
+ An ARM 5 CPU and the corresponding memory-management unit (MM1J)
+ A 16-bit LCD display
+ One or more keyboards (a Qwerty-based keyboard and associated Dpad/Phone buttons)
+ A sound chip among output and input capabilities
+ Flash memory partitions (emulated through disk image flies on the development machine)
+ A GSM modem, including a simulated SIM card
+ A camera, using a webcam connected to our development computer.
➢ The key figure in Google’s implementation of JVM is Dan Bronstein, who has written the
Dalvik VM-Dalvik is the name of a town in Iceland. Dalvik VM takes the generated Java class
files and combines them into one or more Dalvik Executable (.dex) files. It reuses duplicate
information from numerous class files. effectively reducing the gap requirement
(uncompressed) by half from a traditional .jar file.
➢ Android uses the Dalvik virtual machine with just-during time compilation to run Dalvik byte
code, which is frequently translated from Java bytecode. Google has also fine-tuned the
garbage collection in the Dalvik VM, but it has chosen to remove just-in-time(JIT) complier,
in early release.
➢ Android has added JIT, Dalvik VM uses a different kind of assembly-code generation, in
which it uses registers as the primary units of data storage instead of the stack. Google
expects to accomplish 30% lesser instructions as a result. The Dalvik VM relics on the Linux
kernel for underlying functionality such as threading and low-level memory management.
➢ We must remember that the final executable code in Android, as a result of the Dalvik VM, is
based not on Java byte code but on .dex files instead. This means you cannot directly
execute Java byte code: you have to start with Java class files and then convert them to
linkable .dex files.
➢ This performance is extended into the rest of the Android SDK. For example, the Android
SDK uses XML extensively to define UI layouts. However, all of this XML is compiled to binary
files before these binary file-s become resident on the devices. Android provides special
mechanisms to use this XML data.
➢ Android programs are compiled into .dex(Dalvik Executable) files, which are in turn zipped
into a single .apk file on the device. dcx file can be ereatc4 by automatically translating
complied applications written in the Java programming language.
➢ The Dalvik Debug Monitor Service (DDMS) ¡s a key debugging utility that is integrated into
the Eclipse IDE, the favored development environment for Android apps.
Once you launched Android Studio, its time to mention JDK7 path or later version in android studio
installer.
Need to check the components, which are required to create applications, below the image has
selected Android Studio, Android SDK, Android Virtual Machine and performance(Intel chip).
Need to specify the location of local machine path for Android studio and Android SDK, below the
image has taken default location of windows 8.1 x64 bit architecture.
Need to specify the ram space for Android emulator by default it would take 512MB of local
machine RAM.
At final stage, it would extract SDK packages into our local machine, it would take a while time to
finish the task and would take 2626MB of Hard disk space.
After done all above steps perfectly, you must get finish button and it gonna be open android
studio project with Welcome to android studio message as shown below
You can start your application development by calling start a new android studio project. in a new
installation frame should ask Application name, package information and location of the project.
After entered application name, it going to be called select the form factors your application runs
on, here need to specify Minimum SDK, in our tutorial, I have declared as API23: Android
6.0(Mashmallow)
The next level of installation should contain selecting the activity to mobile, it specifies the default
layout for Applications
At the final stage it going to be open development tool to write the application code.
After Click on a virtual device icon, it going to be shown by default virtual devices which are present
on your SDK, or else need to create a virtual device by clicking Create new Virtual device button
If your AVD is created successfully it means your environment is ready for Android application
development. If you like, you can close this window using top-right cross button. Better you re-start
your machine and once you are done with this last step, you are ready to proceed for your first
Android example but before that we will see few more important concepts related to Android
Application Development.
Hello Word Example
Before Writing a Hello word code, you must know about XML tags.To write hello word code, you
should redirect to App>res>layout>Activity_main.xml
To show hello word, we need to call text view with layout ( about text view and layout, you must
take references at Relative Layout and Text View ).
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView android:text="@string/hello_world"
android:layout_width="550dp"
android:layout_height="wrap_content" />
</RelativeLayout>
Need to run the program by clicking Run>Run App or else need to call shift+f10key. Finally, result
should be placed at Virtual devices as shown below