Unit 2
Unit 2
Course Outcome:
Configure Android environment and development tools.
Unit Outcomes:
2a. Describe function of the given component to operate the specified IDE. 2b.
Explain the given term related to virtual machine.
2c. Explain the given basic term related to Android development tools. 2d.
Describe the features of given android emulator.
2e. Describe the steps to configure the given android development environment
---------------------------------------------------------------------------------------------------------------
Contents:
Touchscreen, cellular, Bluetooth, Wi-Fi, GPS mobile navigation, camera, video camera,
speech recognition, voice recorder, music player, etc
An Operating System (OS) is system software that manages computer hardware, software
resources, and provides common services for computer programs.
Time-sharing operating systems schedule tasks for efficient use of the system and may also
include accounting software for cost allocation of processor time, mass storage, printing, and
other resources.
An operating system intermediary between the user of a computer and computer hardware.
The purpose of an operating system is to provide an environment in which a user can execute
programs in a convenient and efficient act as an manner.
An operating system is a software that manages the computer hardware. The hardware must
provide appropriate mechanisms to ensure the correct operation of the computer system and to
prevent user programs from interfering with the proper operation of the system.
Types of Operating Systems
An operating system performs all the basic tasks like managing file, process, and memory.
Thus operating system acts as manager of all the resources, i.e. resource manager. Thus
operating system becomes an interface between user and machine.
Batch Operating System
This type of operating system does not interact with the computer directly. There is an operator
which takes similar jobs having same requirement and group them into batches. It is the
responsibility of operator to sort the jobs with similar needs.
Examples of batch-based operating system are: Payroll System, Bank Statements etc.
Each task is given some time to execute, so that all the tasks work smoothly. Each user gets
time of CPU as they use single system. These systems are also known as Multitasking Systems.
The task can be from single user or from different users also. The time that each task gets to
execute is called quantum. After this time interval is over OS switches over to next task.
These types of operating system is recent advancement in the world of computer technology
and are being widely accepted all-over the world and, that too, with a great pace. Remote access
is enabled within the devices connected in that network.
Network Operating System
These systems run on a server and provide the capability to manage data, users, groups,
security, applications, and other networking functions. These types of operating systems allow
shared access of files, printers, security, applications, and other networking functions over a
small private network.
Examples of network operating system are: Microsoft Windows Server 2003, Microsoft
Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD etc.
Real-Time Operating System
These types of Oss serve the real-time systems. The time interval required to process and
respond to inputs is very small. This time interval is called response time. Real-time systems
are used when there are time requirements are very strict like missile systems, air traffic control
systems, robots etc.
Examples of real-time operating systems are: Scientific experiments, medical imaging systems,
industrial control systems, weapon systems, robots, air traffic control systems etc.
Java JDK
The Java Development Kit (JDK) is a software development environment used for
developing Java applications and applets. It includes the Java Runtime Environment
(JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation
generator (javadoc) and other tools needed in Java development.
The JDK is a software package that contains a variety of tools and utilities that make it
possible to develop, package, monitor and deploy applications that build for any standard
Java platform, including Java Platform, Standard Edition (Java SE); Java Platform, Micro
Edition (Java ME); and Java Platform, Enterprise Edition (Java EE).
JDK is an acronym for Java Development Kit. The Java Development Kit (JDK) is a
software development environment which is used to to develop Java applications and
applets. It physically exists. It contains JRE + development tools,
JDK is an implementation of any one of the below given Java platforms released by Oracle
Corporation:
and a The JDK contains a private Java Virtual Machine (IVM) few other resources such
as an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation
generator (Javadoc), etc. to complete the development of a Java Application.
JVM
JVM (Java Virtual Machine) is an abstract machine.
It is called a virtual machine because it doesn't physically exist. It is a specification
that provides a runtime environment in which Java bytecode can be executed. JVM (Java
Virtual Machine) is an abstract machine. It is a specification that provides runtime
environment in which java bytecode can be executed.
JVMs are available for many hardware and software platforms (i.e. JVM is
platform dependent). JVM is a part of Java Run Environment (JRE).
o Loads code
o Verifies code
o Executes code
o Provides runtime environment
JRE
The Java Runtime Environment (JRE) is a set of software tools for development of Java
applications. It combines the Java Virtual Machine (JVM), platform core classes and
supporting libraries.
JRE is an acronym for Java Runtime Environment. It is also written as Java RTE. The Java
Runtime Environment is a set of software tools which are used for developing Java
applications.
It is used to provide the runtime environment. It is the implementation of JVM. It physically
exists. It contains a set of libraries plus other files that JVM uses at runtime.
The implementation of JVM is also actively released by other companies besides Sun Micro
Systems.
Android SDK
Android development starts with the Android SDK (Software Development Kit). It is a
software development kit that enables developers to create applications for the
Android platform.
The Android SDK (software development kit) is a set of development tools used to develop
applications for Android platform. The Android SDK includes the following:
• Required libraries
• Debugger
• An emulator
• Relevant documentation for the Android application program interfaces (APIs)
• Sample source code
• Tutorials for the Android OS
Xamarin was launched in 2011 which is the best free IDE for delivering an enterprise- quality,
cross-platform approach. Xamarin supplies add-ins to Microsoft Visual Studio that allows
developers to build Android, iOS, and Windows apps within the IDE
3. IntelliJ IDEA
4. Eclipse IDE
It is one of the most popular IDES of Android apps. The open-source software is free to use.
Released under the Eclipse Public License, it holds a large community having plenty of plugins
and configurations. Highly customizable offers full support for Java programming language
and XML.
Android
Developme Languag Target Runs On Audience License Price
nt IDEs es OS
Android Java Android Windows Experienced Freeware Free
Studio C MacOS
C++ Linux
Kotlin
Eclipse Java Android Any OS Professional Eclipse Free
C iOS supportin Developers Public
C++ Linux g Java License
C# MacOS
JavaScript Windows
Python
more
Visual C+ Cross- Windows Experienced Proprieta Free to
Studio (with + C Platform MacOS ry, Visual $2,999
Xamarin) C# Windows Linux Studio +
Visual Android Code is
Basic iOS Open
PHP more Source
JavaScript MIT
more
IntelligJ Java Any OS Windows Professional Proprieta Free to
IDEA Scala supportin MacO Java ry, $499/y
Groovy g Java S Developers Communi ear
Kotlin Linux ty Edition
JavaScript is
TypeScrip Apache
t 2.0
SQL License
NetBeans Java Cross- Windows Professional CDDL 1.0 Free
C platform MacOS Developers and GPL2
C+ Linux
+ Solaris
HTM
L PHP
JavaScript
others
Komodo Java Cross- Windows Professional Proprieta Free to
JavaScript platform MacOS Web and ry, $394+
Python Linux mobile Komodo
PHP developers Edit is
HTML Mozilla
Ruby Public
others License
Cordova HTM Cross- Windows Experienced Apache Free
L CSS platform MacOS Web 2.0
JavaScript Android Linux developers License
Windows
iOS
MacOS
Ubuntu
PhoneGap HTM Cross- Windows Web Apache Free
L CSS platform MacOS developers 2.0
JavaScript Android Linux License
iOS Android
Windows
Phone
App Kawa Android Windows Students and MIT Free
Inventor MacO amateurs License
S
Linux
AIDE Java Android Android Amateurs or Proprieta Free
C Web mobile ry with in-
C++ professionals app
XM purcha
L ses
HTM
L CSS
JavaScript
2. Click Create Virtual Device, at the bottom of the AVD Manager dialog.
The Select Hardware page appears.
Notice that only some hardware profiles are indicated to include Play Store. This indicates
that these profiles are fully CTS compliant and may use system images that include the Play
Store app.
If you see Download next to the system image, you need to click it to download the system
image. You must be connected to the internet to download it.
The API level of the target device is important, because your app won't be able to run on a
system image with an API level that's less than that required by your app, as specified in the
minSdkVersion attribute of the app manifest file. For more information about the relationship
between system API level and minSdkVersion, see Versioning Your Apps.
If your app declares a <uses-library> element in the manifest file, the app requires a system
image in which that external library is present. If you want to run your app on an emulator,
create an AVD that includes the required library. To do so, you might need to use an add-on
component for the AVD platform; for example, the Google APIs add-on contains the Google
Maps library.
The Verify Configuration page appears.
Change AVD properties as needed, and then click Finish.
Now you get a new AVD ready for launching your apps on it.
2.4 Emulators
The Android Emulator simulates Android devices on your computer so that you can test your
application on a variety of devices and Android API levels without needing to have each
physical device.
The emulator provides almost all of the capabilities of a real Android device. You can
simulate incoming phone calls and text messages, specify the location of the device,
simulate different network speeds, simulate rotation and other hardware sensors, access the
Google Play Store, and much more.
Testing your app on the emulator is in some ways faster and easier than doing so on a physical
device. For example, you can transfer data faster to the emulator than to a device connected
over USB.
The emulator comes with predefined configurations for various Android phone, tablet, Wear
OS, and Android TV devices.
In short, An Android emulator is an Android Virtual Device (AVD) that represents a specific
Android device. You can use an Android emulator as a target platform to run and test your
Android applications on your PC. Using Android emulators is optional.
Launch the Android Emulator without first running an app
.
The Android Emulator loads.
While the emulator is running, you can run Android Studio projects and choose the emulator
as the target device. You can also drag one or more APKs onto the emulator to install them,
and then run them.
The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile
devices. It optimizes the virtual machine for memory, battery life and performance.
Dalvik is a name of a town in Iceland. The Dalvik VM was written by Dan Bornstein.
The Dex compiler converts the class files into the .dex file that run on the Dalvik VM. Multiple
class files are converted into one dex file.
Fig.: The compiling and packaging process from the source file
The javac tool compiles the java source file into the class file.
The dx tool takes all the class files of your application and generates a single .dex file. It is a
platform-specific tool.
The Android Assets Packaging Tool (aapt) handles the packaging process.
There is constant pool for every It has constant pool for every class.
application.
Here the executable is APK. Here the executable is JAR.
Follow steps below for complete installation and configuration of Android Studio.
Step 6: Finish
This informs you installation has completed. Click Finish. Make sure Start Android
Studio is checked. Following splash screen of Android Studio will appear.
1: Tool bar- It is collection of many tools like cut, copy, paste, run debug and others. 2:
Navigation bar- It helps you to navigate through the recent open files of your project.
3: Project hierarchy- It is the hierarchy of your project’s folders.
4: Component Tree- It shows component used in an activity in the form of a tree structure.
5: Properties window- It shows properties of selected item on the screen.
6: Layout editor- It shows graphical layout, how your app will look like.
7: Palette window- Palette window shows component, layouts, and widgets available in
Android Studio.
This lesson shows you how to create a new Android project with Android Studio, and it
describes some of the files in the project.
To create your new Android project, follow these steps:
1. Install the latest version of Android Studio.
2. In the Welcome to Android Studio window, click Start a new Android Studio
project.
If you have a project already opened, select File > New > New Project.
3. In the Choose your project window, select Empty Activity and click Next.
4. In the Configure your project window, complete the following:
• Enter "My First App" in the Name field.
• Enter "com.example.myfirstapp" in the Package name field.
• If you'd like to place the project in a different folder, change its Save location.
• Select either Java or Kotlin from the Language drop-down menu.
• Select the checkbox next to Use androidx.* artifacts.
• Leave the other options as they are.
5. Click Finish.
After some processing time, the Android Studio main window appears.
Figure 2. Android Studio main window
Now take a moment to review the most important files.
First, be sure the Project window is open (select View > Tool Windows > Project) and the
Android view is selected from the drop-down list at the top of that window. You can then see
the following files:
In the previous section, you created an Android app that displays "Hello, World!" Youcan now
run the app on a real device or an emulator.
1. In Android Studio, select your app from the run/debug configurations drop-down menu in the
toolbar.
2. In the toolbar, select the device that you want to run your app on from the target device drop-
down menu.
Run on an emulator
4. Click Run .
Android Studio installs the app on the AVD and starts the emulator. You now
see "Hello, World!" displayed in the