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

Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

Lab # 1

Introduction to Android and IDE (Android Studio)


Objective:
To give the basic understanding of the following:

 What is Android
 Installing JDK and environment variables
 Installing Android Studio
 Create "Hello Android World" application
 Running the Application on the Emulator
 The Application Structure
 Android versions and Android SDK Manager

What is a Android?
Android is an open source and Linux-based Operating System for mobile devices such as smart phones
and tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other
companies.

Android offers a unified approach to application development for mobile devices which means
developers need to develop only for Android, and their applications should be able to run on different
devices powered by Android.

The first beta version of the Android Software Development Kit (SDK) was released by Google in 2007,
whereas the first commercial version, Android 1.0, was released in September 2008.

On June 27, 2012, at the Google I/O conference, Google announced the next Android version, 4.1 Jelly
Bean. Jelly Bean is an incremental update, with the primary aim of improving the user interface, both in
terms of functionality and performance. The source code for Android is available under free and open
source software licenses.

Installing JDK and environment variables

1. Install the JDK software.


a. Go to http://java.sun.com/javase/downloads/index.jsp.
b. Select the appropriate JDK software and click Download.

The JDK software is installed on your computer, for example, at C:\Program Files\Java\jdk-11.0.1\bin.
You can move the JDK software to another location if desired.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 1


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

2. Set  JAVA_HOME:
a. Right click My Computer and select Properties.
b. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to
where the JDK software is located, for example, C:\Program Files\Java\jdk1.6.0_02.
Installing Android Studio
You can download Android Studio from this web page:
http://developer.android.com/sdk/index.html
Android Studio is available for Windows, Mac OS X and Linux. Installing Android Studio also downloads
and installs the Android SDK.

Installing on Windows
Follow these steps to install Android Studio on Windows.

1. Double-click the exe file you downloaded to launch the Setup wizard. The
Welcome page of the wizard is shown in Figure 1.1.

3. Click next to proceed.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 2


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

3. You will see the next dialog of the Setup wizard as shown in Figure 1.2. Here you
Can choose the components do install. Leave all components selected and click next
Again.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 3


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

4. The next dialog, shown in Figure 1.3, shows the license agreement. You really
Have no choice but to agree on the license agreement if you wish to use Android
Studio, in which case you have to click I agree.

5. In the next dialog that appears, which is shown in Figure 1.4, browse to the install
Locations for both Android Studio and the Android SDK. Android Studio should
Come with suggestions. It’s not a bad idea to accept the locations suggested. Once
You find locations for the software, click next.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 4


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

8. Once installation is complete, you will see another dialog similar to that in Figure
1.7. Click Next.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 5


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

Creating an Application

Creating an Android application with Android Studio is as easy as a few mouse clicks.
This section shows how to create a Hello World application, package it, and run it on the
Emulator. Make sure you have installed the Android SDK and Android Studio by
Following the instructions in the previous section.

Next, follow these steps.


1. Click the File menu in Android Studio and select New Project. The first dialog of
The Create New Project wizard, shown in Figure 1.12, appears.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 6


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

2. Enter the details of the new application. In the Application name field, type the Name to appear on
the Android device. In the Company Domain field, type your Company’s domain. If you do not have one,
just use example.com. The company Domain in reverse order will be used as the base package name for
the application. The package name uniquely identifies your application. You can change the package
Name by clicking the Edit button to the right of the field. By default, the project will be created under
the AndroidStudioProjects directory created when you installed Android Studio. You can change the
location too if you wish.

3. Click Next. The second dialog opens as shown in Figure 1.13. Here you need to Select a target (phone
and Tablet, TV, etc) and the minimum API level. This book Only discusses Android application
development for phones and tablets, so leave the Selected option checked. As for the minimum API
level, the lower the level, the more Devices your application can run on, but the fewer features are
available to you. For Now, keep the API level Android Studio has selected for you.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 7


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 8


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

4. Click next again. A dialog similar to that in Figure 1.14 appears. Android Studio is asking you if you
want to add an activity to your project and, if so, what kind of activity. At this stage, you probably do not
know what an activity is. For now, think of it as a window, and add a blank activity to your project. So,
accept the selected activity type.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 9


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

5. Click next again. The next dialog that appears looks like the dialog in Figure 1.15.
In this dialog you can enter a Java class name for your activity class as well as a title
for your activity window and a layout name. For now just accept the default.

6. Click Finish. Android Studio will prepare your project and it may take a while.
Finally, when its finished, you will see your project in Android Studio, like the one
Shown in Figure 1.16.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 10


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

The next section shows you how you can run your application on the emulator.

Running the Application on the Emulator

Now that you have an application ready, you can run it by clicking the Run button. You
Will be asked to choose a device.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 11


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

If you have not created an emulator, do so now. If you have, you will see all running Emulators. Or, you
can launch one. Click Use same device for future launches to use the same emulator in the future.
Next, click OK. It will take seconds to launch the AVD. As you know, the emulator emulates an Android
Device. Just like a physical device, you need to unlock the emulator’s screen when running
Your app for the first time. If your application does not open automatically, locate the application icon
and double-click on it. Figure 1.18 shows the application you just created.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 12


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

During development, leave the emulator running while you edit your code. This way, the Emulator does
not need to be loaded again every time you test your application.

The Application Structure

Now, after the little excitement of having just run your first Android application, let’s go back to Android
Studio and take a look at the structure of an Android application. Figure 1.19 shows the left tree view
that contains the project components.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 13


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

There are two main nodes in the Project window in Android Studio, app and Gradle Scripts. The app
node contains all the components in the application. The Gradle Scripts node contains the Gradle build
scripts used by Android Studio to build your project. I will not discuss these scripts, but it would be a
good idea for you to get familiar with Gradle.

There are three nodes under the app node:

Manifests. Contains an AndroidManifest.xml file that describes your application. It will be explained in
more detail in the next section The Android Manifest.java. Contains all Java application and test classes.
Res. Contains resource files. Underneath this directory are these directories:

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 14


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

Drawable (containing images for various screen resolutions), layout (containing Layout files), menu
(containing menu files) and values (containing string and other Values).

Android versions and Android SDK Manager

These are the Android version are listed below:

Android SDK Manager separates the APIs, tools and different platforms into
different packages which you can download.

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 15


Android Development: Lab#1, Introduction to Android and IDE (Android Studio)

Exercise
1. Install latest version of Android Studio, JDK and SDK at your home PCs (Screen Shots).
2. Create Project for hello world in the Android. (Screen Shots).

LAB INSTRUCTOR: MURTAZA KHALID SALEEM 16

You might also like