This document provides an overview of an Android application development session that covers topics from the basics of Android to an advanced level. It discusses introducing Android and the Android SDK. It describes how to set up the development environment on Windows and Linux and install the Android Development Tools plugin for Eclipse. It demonstrates how to create an Android project in Eclipse and build a simple "Hello World" application. It also explains the structure of an Android project directory and the purpose of key directories like res, src, and values.
2. Topics to be Covered
1.
Introduction of Android.
2.
Android SDK.
3.
Setting Up Development Environment (Windows,Linux).
4.
Creating Project in Eclipse.
5.
Tutorial-1: Hello World
6.
Android Project Directory Structure.
3. 1. Introduction of Android
●
Android is a Linux-based operating system designed primarily for
touchscreen mobile devices such as smartphones and tablet computers,
developed by Google in conjunction with the Open Handset Alliance.
●
Initially developed by Android Inc, whom Google financially backed and
later purchased in 2005.
●
Android has a large community of developers writing applications ("apps")
that extend the functionality of devices, written primarily in a customized
version of Java.They are available for download through Google Play or
third-party sites.
●
The first Android-powered phone was sold in October 2008, and by the
end of 2010 Android had become the world's leading smartphone platform,
overtaking Symbian which held its record for years
4. 2. Android SDK
●
The Android SDK (SDK refers to Software Development KIT)provides you
the API libraries and developer tools necessary to build, test, and debug
apps for Android.
●
Like in windows we have .NET Framework as a SDK for developing the
Softwares for windows platform.Similarly java provide JDK(Java Dev. Kit).
But java provide kit for Linux as well as for windows.
●
To Download SDK: http://developer.android.com/sdk/index.html
●
To know more about Android SDK: http://developer.android.
com/sdk/exploring.html
5. 3. Dev Environment
System Requirements.(OS) (http://developer.android.com/sdk/index.html)
●
●
●
Windows XP (32-bit), Vista (32- or 64-bit), or Windows 7 (32- or 64-bit)
Mac OS X 10.5.8 or later (x86 only)
Linux (tested on Ubuntu Linux, Lucid Lynx)
GNU C Library (glibc) 2.7 or later is required.
On Ubuntu Linux, version 8.04 or later is required.
64-bit distributions must be capable of running 32-bit applications.
Eclipse IDE
●
●
●
●
Eclipse 3.6.2 (Helios) or greate ()
Android SDK
JDK 6 (JRE alone is not sufficient)
Android Development Tools plugin (ADT)
6. 3. Dev Environment (Cont.)
●
After Downloading Android SDK,We have to download platform packages.
7. 3. Dev Environment (Cont.)
●
Once we are done with downloading platform packages either we are
developing on Windows or Linux or Mac we need to install ADT (Android
Development Toolkit) in Eclipse IDE.
To Install ADT into the Eclipse IDE follow below steps.
1. Open Eclipse IDE.
2. Click on Help->Install New Software from the menu bar.
3. Then install window is open then Click on Add Button
8. 3. Dev Environment (Cont.)
●
Now when you click on Add button,you will found below window.
Insert the Name as ADT(any name can be given) and Location of ADT zip file.
Location can be given by clicking on Archive button and then press Ok.
9. 3. Dev Environment (Cont.)
Setting up SDK path into Eclipse IDE
● Open Preferences window by clicking Window -> Preferences.
●
If we have properly installed ADT in Eclipse we have Android option in
Preferences window.
●
As you can see on above image by Clicking on Android in preferences
window we have option available for SDK path.
●
So by clicking Browse button please select android-sdk-window folder
from your computer.so SDK location field have complete path of Android
SDK.So finally you have a setup ready for Android Development.
10. 4.Creating Project in Eclipse
●
●
Open Eclipse IDE.
Click on File->New->Android Project
from file menu.
●
Application Name is the app name that
appears to users. For this project, use "My
First App."
Project Name is the name of your project
directory and the name visible in Eclipse.
Package Name is the package
namespace for your app.
Minimum Required SDK is the lowest
version of Android that your app supports,
indicated using the API level.
Target SDK indicates the highest version
of Android (also using the API level) with
which you have tested with your
application.
Compile With is the platform version
against which you will compile your app.
Click on Next button.
●
●
●
●
●
●
11. 4.Creating Project in Eclipse
●
●
●
The next screen can help you create a launcher icon for your app.Click
Next.
Now you can select an activity template from which to begin building your
app. For this project, select BlankActivity and click Next
Finally click on the Finish.
12. 5.Tutorial-1: Hello World
●
After creating project in eclipse ,run the project by right click on the project
name and Runs As -> Android Application.
●
If simulator is created previously project will run in that other wise it eclipse
will ask for create new simulator.
13. 6.Android Project Directory
Structure.
●
Now we are learning how this hello world is printed
on the screen.
●
Following Image shows android project directory
structure.
●
src: This is the directory where all java files for the
project will reside. In java there is a concept of
package so here files are maintained in packages.
Like in our case there is one package called com.
maktabah which we have entered at the time of
project creation.
●
gen: In this folder the files which are generated by
android-sdk.We are not changing any of the files
here,Because this is the internal reference to sdk.
14. 6.Android Project Directory
Structure.
●
assets: Here resource type information will goes.Like
fonts file,web-pages(when we are developing android
app in HTML5)
●
bin: When are compiling the project all class files are
generated here by java compiler.
●
res: This is important folder we are discussing each
inner directory in detail.
●
drawable-hdpi,drawable-ldpi,drawable-mdpi,
drawable-xhdpi: These are the directories where we
are putting images that are used in projects.
○ But we have question like why these many
directories(4 directories).So the answer is these
are the directory dedicated for different screen
density(in Desktop computer terminology we call
it resolution of the Monitor).
15. 6.Android Project Directory
Structure.
○
●
How android app decide which image to talk
when it is referenced from code we will see it
when we see implementation of the sample
tutorial.
To read more about for these directories please follow
the link:
http://developer.android.
com/guide/practices/screens_support.html
●
Consider following image for example.
16. 6.Android Project Directory
Structure.
i.
ii.
iii.
iv.
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
●
layout: This is the directory where we are putting all design
files in xml format.As we can see from right side image
when we create new project default main.xml file is there.
●
These layout xmls files are responsible for the userinterface and look and feel of the app.
●
Like in windows application when we are working in visual
studio IDE we have two files one for design and one for
code.Whenever we place button in design and double click
on it and button_click function in different file and button
User interface is in design file
18. 6.Android Project Directory
Structure.
●
values: It contains all xml file for values like styles xml,
string constants and other.
●
As we can see im right side image the when we create a
new android project it only contains string.xml which
contains strings values in xml format for whole project.
●
Strings for lable,error message and titles etc are stored in
string.xml files.We can also write strings at lable in
layout.xml, but it is good practice to declare strings in
string.xml for managing resource in project and
reusability
20. 6.Android Project Directory
Structure.
AndroidManifest.xml:
●
This is the file where we declaring application components like Activities,
Services,Broadcast-Receivers.
●
Allowing permissions to application
●
We can also call it is a configuration file for the app.