Unit-2- installation and configuration of android (1)
Unit-2- installation and configuration of android (1)
Course Outcome:
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:
Touch screen, cellular, Bluetooth, Wi-Fi, GPS mobile navigation, camera, video camera,
speech recognition, voice recorder, music player, etc
Java JDK
The Java Development Kit (JDK) is a software development environment used for
developingJavaapplicationsandapplets.ItincludestheJavaRuntimeEnvironment (JRE), an
interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation
generator (javadoc) and other tools needed in Java development.
JVM
1
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.JVMisplatform
dependent). JVM is a part of Java Run Environment (JRE).
o Loads code
o Verifies code
o Executes code
o Provides run time 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.
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
AndroidhasGradle-basesupportthathasfeatureslikevisuallayouteditor,intelligent
codeeditor,real-timeprofilersandAPKanalyzer.ItactsjustlikeanyotherJavaIDEin terms
of error investigating and file hierarchy.
2
2. VisualStudio–Xamarin
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. EclipseIDE
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, ith old salarge community having plenty
of plugins and configurations. Highly customizable offers full support for Java
programming language and XML.
Android
Developme Languag Target RunsOn Audience License Price
ntIDEs es OS
Android Java Android Windows Experienced Freeware Free
Studio C MacOS
C++ Linux
Kotlin
Eclipse Java Android Any OS Professional Eclipse Free
C iOSLinux supportin Developers Public
C++ MacOS g Java License
C# Windows
JavaScript
Python
more
Visual C++ Cross- Windows Experienced Proprieta Freeto
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 AnyOS Windows Professional Proprieta Freeto
3
IDEA Scala supportin MacOS Java ry, $499/y
Groovy g Java Linux Developers Communi ear
Kotlin tyEdition
JavaScript is
TypeScrip Apache
t 2.0
SQL License
NetBeans Java Cross- Windows Professional CDDL1.0 Free
C platform MacOS Developers andGPL2
C++ Linux
HTML Solaris
PHP
JavaScript
others
Komodo Java Cross- Windows Professional Proprieta Freeto
JavaScript platform MacOS Web and ry, $394+
Python Linux mobile Komodo
PHP developers Edit is
HTML Mozilla
Ruby Public
others License
Cordova HTML Cross- Windows Experienced Apache Free
CSS platform MacOS Web 2.0
JavaScript Android Linux developers License
Windows
iOS
MacOS
Ubuntu
PhoneGap HTML Cross- Windows Web Apache Free
CSS platform MacOS developers 2.0
JavaScript Android Linux License
iOS Android
Windows
Phone
App Kawa Android Windows Studentsand MIT Free
Inventor MacOS amateurs License
Linux
AIDE Java Android Android Amateurs or Proprieta Free
C Web mobile ry within-
C++ professionals app
XML purcha
HTML ses
CSS
JavaScript
4
Simulate in the Android Emulator. The AVD Manager is an interface you can launch from
Android Studio that helps you create and manage AVDs.
2. Click Create Virtual Device, at the bottom of the AVD Manager dialog.
The Select Hardware page appears.
5
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.
3. Select a hardware profile, and then click Next.
If you don't see the hardware profile you want, you can create or import a hardware
profile.
6
4. Select the system image for a particular API level, and then click Next.
The Recommended tab lists recommended system images. The other tabs include a
morecompletelist.Therightpanedescribestheselectedsystemimage.x86imagesrun the
fastest in the emulator.
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 min Sdk Version attribute of the app manifest file. For more information about
the relationship between system API level and min Sdk Version, 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
anemulator,createanAVDthatincludestherequiredlibrary.Todoso,youmightneed
touseanadd-oncomponentfortheAVDplatform;forexample,theGoogleAPIsadd-on
contains the Google Maps library.
TheVerifyConfigurationpageappears.
7
ChangeAVDpropertiesasneeded,andthenclickFinish.
NowyougetanewAVDreadyforlaunchingyourappsonit.
2.4 Emulators
TheAndroidEmulatorsimulatesAndroiddevicesonyourcomputersothatyoucantest
yourapplication on a varietyofdevices andAndroid APIlevels without needingtohave
each physical device.
TheemulatorprovidesalmostallofthecapabilitiesofarealAndroiddevice.Youcan 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.
Testingyourappontheemulatorisinsomewaysfasterandeasierthandoingsoona physical
device. For example, you can transfer data faster to the emulator than to a device
connected over USB.
TheemulatorcomeswithpredefinedconfigurationsforvariousAndroidphone,tablet, Wear
OS, and Android TV devices.
8
In short, AnAndroid emulatoris anAndroidVirtual Device (AVD) that represents a
specificAndroiddevice. You can use anAndroid emulatoras a target platform to run
and test your Android applications on your PC. Using Android emulators is optional.
LaunchtheAndroidEmulatorwithoutfirstrunninganapp
Tostarttheemulator:
1. OpentheAVDManager.
2. Double-clickanAVD,orclickRun
.
TheAndroidEmulatorloads.
While the emulator is running, you can run Android Studio projects and choose the
emulatorasthetargetdevice.YoucanalsodragoneormoreAPKsontotheemulatorto install
them, and then run them.
2.5 DalvikVirtualMachine(DVM)
As we know the modern JVM is high performance and provides excellent memory
management.Butitneedstobeoptimizedforlow-poweredhandhelddevicesaswell.
TheDalvikVirtualMachine(DVM)isanandroidvirtualmachineoptimizedformobile
devices. It optimizes the virtual machine for memory, battery life and performance.
DalvikisanameofatowninIceland.TheDalvikVMwaswrittenbyDanBornstein.
TheDexcompilerconvertstheclassfilesintothe.dexfilethatrunontheDalvikVM. Multiple
class files are converted into one dex file.
Fig.:Thecompilingandpackagingprocessfromthesourcefile
9
Thejavactoolcompilesthejavasourcefileintotheclassfile.
Thedxtooltakesalltheclassfilesofyourapplicationandgeneratesasingle.dexfile.It is a
platform-specific tool.
DVM(DalvikVirtualMachine) JVM(JavaVirtualMachine)
ItisRegisterbasedwhichisdesignedto run ItisStackbased.
on low memory.
DVM uses its own byte code and runs JVMusesjavabytecodeandruns“.class” file
“.Dex”file.FromAndroid2.2SDKDalvik having JIT (Just In Time).
has got a Just in Time compiler
DVMhasbeendesignedsothatadevice can SingleinstanceofJVMissharedwith
run multiple instances of the VM multiple applications.
efficiently. Applications are given their
own instance.
DVMsupportsAndroidoperating system JVMsupportsmultipleoperating systems.
only.
ForDVMveryfewRe-toolsareavailable. ForJVMmanyRe-toolsareavailable.
Thereisconstantpoolforevery Ithasconstantpoolforeveryclass.
application.
HeretheexecutableisAPK. HeretheexecutableisJAR.
2.6 StepstoinstallandconfigureAndroidStudioandSDK
Installation
FollowstepsbelowforcompleteinstallationandconfigurationofAndroidStudio.
Step1)DownloadAndroidStudio
YoucandownloadAndroidStudiofromthislinkorgo
todeveloper.android.comhomepageandsearchfordownloads.Chooseappropriate
platform either for windows, mac or linux. Following are the pre requirements for
windows operating system.
Pre-requirements
Microsoftwindows7/8/10(32or64bits)
Minimum3GBRAM(recommended8GB)
2GBdiskspace
1280x800minimumscreenresolutionsize
Intelprocessorforacceleratedemulator
AndroidSDK
10
Note:Ifyoudon’thaveAndroidSDK,youcandownloadwithAndroidstudio.Gotothe end of
download’s page and find android-studio-bundle-162.4069837-windows.exe it
includes SDK also.
Step2)Run.exefile
Nowthenextstepistolaunch.exefileyoujustdownload.Followingscreenwillappear
Step1:Run.exe file
ClicknextandselectAndroidSDKcheckedifyoudon’thaveitalready. Betteristoleave the
default settings.
MakesureAndroidvirtualdeviceisalsochecked.
11
Step 2: Choose components
Nextstepistoacceptlicenseandagreement.ClickonIAgree
Step3:Acceptlicense
Next step is to set location of installation. Please make sure your disk has minimum
requiredspacebeforeclickingonNext.ForAndroidStudioinstallationlocationmust
12
haveatleast500MBfreespace.ForAndroidSDKinstallation,selectedlocationmust have at
least 3.25GB free space.
Step4:Installlocation
Nextstepistochoosethestartmenufolder,whereyouwanttocreateshortcut.Ifyou don’t
want to create a shortcut just mark Do not create shortcut.
13
Step5:Choosestartmenufolder
AndhitInstallbutton.
Itwillstartinstallation.Onceit’sdonefollowingwindowwillappear.
Step6:Finish
Thisinformsyouinstallationhascompleted.ClickFinish.MakesureStartAndroid Studio is
checked. Following splash screen of Android Studio will appear.
Step7:AndroidStudioSplashScreen
Step3)ConfigureAndroidStudio
14
WhenyourunitforthefirsttimeitwillaskforAndroidStudiosettings.
Step8:Importsettings
Ifyoudon’thaveanyprevioussettingsclickonthesecondoption(Idon’thavea previous
version of Studio or I don’t want to import my settings).
Selectathemeandclicknext.
Step9:Selecttheme
15
Attheveryfirstrunitneedstodownloadsomenecessarycomponents,waittillit completes.
Step10:Downloadcomponents
And it’s all done.
16
Step 11: Done
ClickonFinishandstartbuildingyourAndroidapps.
IntroductiontoAndroidStudioUserInterface
Android Studio is an Integrated Development Environment (IDE). You have seen
downloadandinstallationinthistutorial.Let’slearnsomebasicsofAndroidStudio. Here is
the a screenshot of a running Android studio.
17
AndroidStudioscreen
Redmarkshows
1:Toolbar-Itiscollectionofmanytoolslikecut,copy,paste,rundebugandothers. 2:
Navigation bar- It helps you to navigate through the recent open files of your
project.
3:Projecthierarchy-Itisthehierarchyofyourproject’sfolders.
4:ComponentTree-Itshowscomponentusedinanactivityintheformofatree structure.
5:Propertieswindow-Itshowspropertiesofselecteditemonthescreen.
6:Layouteditor-Itshowsgraphicallayout,howyourappwilllooklike.
7:Palettewindow-Palettewindowshowscomponent,layouts,andwidgetsavailable in
Android Studio.
CreateanAndroidproject
ThislessonshowsyouhowtocreateanewAndroidprojectwithAndroidStudio,andit
describes some of the files in the project.
TocreateyournewAndroidproject,followthesesteps:
1. InstallthelatestversionofAndroidStudio.
18
2. IntheWelcometoAndroidStudiowindow,clickStartanewAndroidStudio
project.
Figure1.AndroidStudiowelcomescreen
Ifyouhaveaprojectalreadyopened,selectFile>New>NewProject.
3. IntheChooseyourprojectwindow,selectEmptyActivityandclickNext.
4. IntheConfigureyourprojectwindow,completethefollowing:
Enter"MyFirstApp"intheNamefield.
Enter"com.example.myfirstapp"inthePackagenamefield.
Ifyou'dliketoplacetheprojectinadifferentfolder,changeitsSavelocation.
SelecteitherJavaorKotlinfromtheLanguagedrop-downmenu.
SelectthecheckboxnexttoUseandroidx.*artifacts.
Leavetheotheroptionsastheyare.
5. ClickFinish.
Aftersomeprocessingtime,theAndroidStudiomainwindowappears.
19
Figure2.AndroidStudiomainwindow
Nowtakeamomenttoreviewthemostimportantfiles.
First,besuretheProjectwindowisopen(selectView>ToolWindows>Project)and the
Android viewis selectedfromthe drop-down list at the top ofthatwindow. Youcan then
see the following files:
app>java>com.example.myfirstapp>MainActivity
app>res>layout>activity_main.xml
ThisXMLfiledefinesthelayoutfortheactivity'suserinterface(UI).Itcontains a
TextView element with the text "Hello, World!"
app>manifests>AndroidManifest.xml
Themanifestfiledescribesthefundamentalcharacteristicsoftheappand defines
each of its components.
GradleScripts>build.gradle
20
module'sbuild.filetocontrolhowtheGradlepluginbuildsyourapp.Formore
information about this file, see Configure your build.
Runyourapp
Runonarealdevice
Setupyourdeviceasfollows:
1. ConnectyourdevicetoyourdevelopmentmachinewithaUSBcable.Ifyoudeveloped on
Windows, you might need to install the appropriate USB driver for your device.
2. PerformthefollowingstepstoenableUSBdebuggingintheDeveloper
options window:
a. OpentheSettingsapp.
b. IfyourdeviceusesAndroidv8.0orhigher,selectSystem.Otherwise,proceedtothe next
step.
c. ScrolltothebottomandselectAboutphone.
d. ScrolltothebottomandtapBuildnumberseventimes.
e. Returntothepreviousscreen,scrolltothebottom,andtapDeveloperoptions.
f. IntheDeveloperoptionswindow,scrolldowntofindandenableUSBdebugging. Run
1. InAndroidStudio,selectyourappfromtherun/debugconfigurationsdrop-downmenu in
the toolbar.
2. Inthetoolbar,selectthedevicethatyouwanttorunyourapponfromthetargetdevice drop-
down menu.
21
Figure1.Targetdevicedrop-downmenu
1. ClickRun .
AndroidStudioinstallsyourapponyourconnecteddeviceandstartsit.Younowsee "Hello,
World!" displayed in the app on your device.
Tobegintodevelopyourapp,continuetothenextlesson.
Runonanemulator
Runtheapponanemulatorasfollows:
1. InAndroidStudio,createanAndroidVirtualDevice(AVD)thattheemulatorcanuseto install
and run your app.
2. Inthetoolbar,selectyourappfromtherun/debugconfigurationsdrop-downmenu.
3. Fromthetargetdevicedrop-downmenu,selecttheAVDthatyouwanttorunyourapp on.
22
Figure2.Targetdevicedrop-downmenu
4. ClickRun .
AndroidStudioinstallstheappontheAVDandstartstheemulator.Younowsee"Hello,
World!" displayed in the app.
Revision Diagram
Android
Studio
Gradle
FlowUp
Geney
Motion
Game
Maker
etc.
23