Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Download and install Android Studio

Android Studio is the official integrated development environment (IDE) for


Android app development built and distributed by Google. An IDE contains tools
that make it easy for software developers to design, build, run, and test
software, in this case, apps for the Android platform. Android Studio uses IntelliJ
IDEA as its foundation and includes the Android plugin pre-installed along with
some modifications specifically for the Android platform.

To get up and running with Android Studio:

 First need to install the Java Development Kit - Java 7 or better.


 Install Android Studio

To download the Java Standard Edition () Development Kit (JDK):

• Download JDK for your OS


https://www.oracle.com/in/java/technologies/downloads/#jdk19-windows

Installing Android Studio


1. After installing JDK, download Android SDK from http://developer.android.com
Download and install Android Studio bundle (including Android SDK) for your OS

This is the Android Developers website, where you can download Android
Studio. This page automatically detects your operating system.

2. Click Download Android Studio. The Terms and Conditions page with the
Android Studio License Agreement opens.
3. At the bottom of the page, if you agree with the terms and conditions,
select the I have read and agree with the above terms and
conditions checkbox.
4. Click Download Android Studio to start the download.
5. When prompted, save the file to a location where you can easily locate it,
such as the Downloads folder.
6. Open the folder where you downloaded and saved the Android Studio
installation file.
7. Double-click the downloaded file.
1. The Welcome to Android Studio Setup dialog displays.
1|Page Manorama Darekar,Gurukul College.
2. Click Next to start the installation.
3. Accept the default installation settings for all steps.
4. Click Finish when the installation is done to launch Android Studio.

2|Page Manorama Darekar,Gurukul College.


3|Page Manorama Darekar,Gurukul College.
4|Page Manorama Darekar,Gurukul College.
5. Choose your preference of light or dark theme when Android Studio first
launches. Screenshots in this course use the light theme, but choose whichever
one you prefer.
6. During the installation, the setup wizard downloads and installs additional
components and tools needed for Android app development. Be patient, this
might take some time depending on your Internet speed, and some of the steps
may seem redundant. During this time, you may see a User Account
Control dialog for Windows Command Processor. Click Yes to accept the dialog.
When the download completes, Android Studio will start, and you are ready to
create your first project.

5|Page Manorama Darekar,Gurukul College.


Practical No 1
Title : Introduction to Android, Introduction to Android Studio IDE, Application
Fundamentals: Creating a Project, Android Components, Activities, Services, Content
Providers, Broadcast Receivers, Interface overview, Creating Android Virtual device, USB
debugging mode, Android Application Overview. Simple “Hello World” program.

Introduction : Android Studio is Google's IDE for Android apps. Android Studio gives you
an advanced code editor and a set of app templates. In addition, it contains tools for
development, debugging, testing, and performance that make it faster and easier to
develop apps. You can test your apps with a large range of preconfigured emulators or on
your own mobile device, and build production APKs for publication.

Android - Application Components


Application components are the essential building blocks of an Android application. These
components are loosely coupled by the application manifest file AndroidManifest.xml that
describes each component of the application and how they interact.
There are following four main components that can be used within an Android application
1. Activity
An activity is the entry point for interacting with the user. It represents a single screen
with a user interface. In-short Activity performs actions on the screen.

2. Services
A service is a component that runs in the background to perform long-running
operations. A service does not provide a user interface. For example, a service might
play music in the background while the user is in a different application, or it might
fetch data over the network without blocking user interaction with an activity.

3. Broadcast Receivers
They handle communication between Android OS and applications.. Broadcast
Receivers simply respond to broadcast messages from other applications or from the
system. A broadcast receiver is a component that enables the system to deliver events
to the app outside of a regular user flow, allowing the app to respond to system-wide
broadcast announcements.

4. Content Providers
A content provider component supplies data from one application to others on
request. A content provider manages a shared set of app data that you can store in
the file system, in a SQLite database, on the web, or on any other persistent storage
location that your app can access.

1|Page Manorama Darekar,Gurukul College.


To create a project in Android Studio:
1. Double click the Android Studio icon to launch Android Studio.

2. In the Welcome to Android Studio dialog, click New Project.

The New Project window opens with a list of templates provided by Android Studio.
In Android Studio, a project template is an Android project that provides the blueprint for a
certain type of app. Templates create the structure of the project and the files needed for
Android Studio to build your project. Based on the template that you choose, it provides
starter code to get you going faster.

2|Page Manorama Darekar,Gurukul College.


3. Make sure the Phone and Tablet tab is selected.
4. Click the Empty Compose Activity template to select it as the template for your project.
The Empty Compose Activity template is the template to create a simple project that you can
use to build a Compose app. It has a single screen and displays the text "Hello World !".
5. Click Next. The New Project dialog opens. This has some fields to configure your project.

The Name field is used to enter the name of your project, for this codelab type "FirstApp".

Leave the Package name field as is. This is how your files will be organized in the file structure.
In this case, the package name will be com.example.FirstApp

Select the Save location field as you required. It contains the location where all the files
related to your project are saved.

Kotlin is already selected in the Language field. Language defines which programming
language you want to use for your project. Since Compose is only compatible with Kotlin, you
cannot alter this field.

Select API 21: Android 5.0 (Lollipop) from the menu in the Minimum SDK field. Minimum
SDK indicates the minimum version of Android that your app can run on.

The Use legacy android.support libraries checkbox is already unchecked.

6. Hit Finish. This may take a while depending upon speed of your Internet Connection .While
Android Studio is setting up, a progress bar and message indicates whether Android Studio is
still setting up your project.

3|Page Manorama Darekar,Gurukul College.


Downloads required SDK components while setup. In Android Studio, select Tools > SDK
Manager, or click the SDK Manager icon in the toolbar to check installed SDK in
system.

Click Split on the top right of Android Studio, this allows you to view both code and design.
You can also click Code to view code only or click Design to view design only.

4|Page Manorama Darekar,Gurukul College.


Create a virtual device (Emulator)
Device Manager is used to create a virtual device or emulator that simulates the
configuration for a particular type of Android device.

Using the Device Manager, define the hardware characteristics of a device and its API level,
and save it as a virtual device configuration.

When you start the Android emulator, it reads a specified configuration and creates an
emulated device that behaves exactly like a physical version of that device , but it resides
on your computer .

Create a virtual device


In Android Studio, select Tools > Device Manager, or click the Device Manager

icon in the toolbar.

1. Click the Create Device…. (If you have created a virtual device before, the window shows
all of your existing devices and the button is at the bottom.)

5|Page Manorama Darekar,Gurukul College.


The Select Hardware screen appears showing a list of preconfigured hardware devices. For
each device, the table shows its diagonal display size (Size), screen resolution in pixels
(Resolution), and pixel density (Density).

3.Choose the Nexus 5 hardware device and click Next.

4.On the System Image screen, from the Recommended tab, choose which version of the
Android system to run on the virtual device. You can select the latest system image.

There are many more versions available than shown in the Recommended tab. Look at
the x86 Images and Other Images tabs to see them.

6|Page Manorama Darekar,Gurukul College.


If a Download link is visible next to a system image version, it is not installed yet, and you
need to download it. If necessary, click the link to start the download, and click Finish when
it's done.

On System Image screen, choose a system image and click Next.

5.Verify your configuration, and click Finish.

7|Page Manorama Darekar,Gurukul College.


Run your app on an emulator

1. In Android Studio, select Run > Run app or click the Run icon in the toolbar.
2. In the Device Manager window, under Available Emulators, select Nexus 5 API 33 and
click OK.

The emulator starts and boots just like a physical device. Depending on the speed of your
computer, this may take a while. Your app builds, and once the emulator is ready, Android
Studio will upload the app to the emulator and run it.

8|Page Manorama Darekar,Gurukul College.


Run your app on a device
Run your app on a physical mobile device such as a phone or tablet.

Requirement:

 An Android device such as a phone or tablet.


 A data cable to connect your Android device to your computer via the USB port.

To let Android Studio communicate with your device, turn on USB Debugging on your
Android device. This is enabled in the Developer options settings of your device. Note this
is not the same as rooting your device.

On Android 4.2 and higher, the Developer options screen is hidden by default. To show
Developer options and enable USB Debugging:

1. On your device, open Settings > About phone and tap Build number seven times.
2. Return to the previous screen (Settings). Developer options appears at the bottom of the
list. Click Developer options.
3. Choose USB Debugging.

Now connect your device and run the app from Android Studio.

1. Connect your device to your development machine with a USB cable.


2. Click the Run button in the toolbar.

3. Select your device, and click OK.

Android Studio should install and runs the app on your device.

9|Page Manorama Darekar,Gurukul College.


Explore the project structure

In the Project > Android view of your previous task, there are three top-level folders below
your app folder: manifests, java, and res.
1. Expand the manifests folder.

This folder contains AndroidManifest.xml. This file describes all of the components of your
Android app and is read by the Android run-time system when your program is executed.

2. Expand the java folder. All your Kotlin language files are organized in this folder.
The java folder contains three subfolders:
 com.example.hello.firstapp (or the domain name you have specified): All the files for
a package are in a folder named after the package. For your Hello World application,
there is one package and it only contains MainActivity.kt (the file extension may be
omitted in the Project view).
 com.example.hello.firstapp (androidTest): This folder is for your instrumented tests,
and starts out with a skeleton test file.
 com.example.hello.firstapp (test): This folder is for your unit tests and starts out with
an automatically created skeleton unit test file.

3. Expand the res folder. This folder contains all the resources for your app, including
images, layout files, strings, icons, and styling. It includes these subfolders:

10 | P a g e Manorama Darekar,Gurukul College.


 drawable. Store all your app's images in this folder.
 layout. Every activity has at least one layout file that describes the UI in XML. For Hello
World, this folder contains activity_main.xml.
 mipmap. Store your launcher icons in this folder. There is a sub-folder for each supported
screen density. Android uses the screen density, that is, the number of pixels per inch to
determine the required image resolution. Android groups all actual screen densit ies into
generalized densities, such as medium (mdpi), high (hdpi), or extra-extra-extra-high
(xxxhdpi). The ic_launcher.png folder contains the default launcher icons for all the
densities supported by your app.
 values. Instead of hardcoding values like strings, dimensions, and colors in your XML and
Java files, it is best practice to define them in their respective values file. This makes it
easier to change and be consistent across your app.

The Gradle build system


Android Studio uses Gradle as its build system. Expand the Gradle Scripts folder. This
folder contains all the files needed by the build system. This is an auto generated file which
contains compileSdkVersion, buildToolsVersion, applicationId, minSdkVersion,
targetSdkVersion, versionCode and versionName
Look for the build.gradle(Module:app) file. When you are adding app-specific
dependencies, such as using additional libraries, they go into this file.

11 | P a g e Manorama Darekar,Gurukul College.

You might also like