Tải bản đầy đủ (.pptx) (34 trang)

02 getting started with android development

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (977.34 KB, 34 trang )

Android Basic Course
© 2012 University of Science – HCM City
.
Module 2: Getting Started with Android Development
M.Sc. Bui Tan Loc

Department of Software Engineering,
Faculty of Information Technology,
University of Science – Ho Chi Minh City, Viet Nam
Android Basic Course
© 2012 University of Science – HCM City
.
Objectives

After completing this module, you will have learned:

About installing the Android development environment

About using SDK Manager and AVD Manager

About Android project structure

About launching an Android application with different emulators corresponding different platforms

About DDMS tools

About how to debug an application

About changing xml resource file by GUI or Text editor.
2
Android Basic Course


© 2012 University of Science – HCM City
.
Contents

Getting to install the Android development environment

Getting to know Android SDK tools

Getting to know Android project structure

Getting to know how to run with the default emulator

Getting to know how to run with the specified emulator

Getting to know DDMS tools

Getting to know how to debug with the default emulator

Getting to know how to change xml resource files
3
Android Basic Course
© 2012 University of Science – HCM City
.
Getting to install the Android development environment

Supported OS:

Windows, Mac OS X, Linux

Pre-requirement:


JDK
1. Installing Editor:

Eclipse (Eclipse classic version is recommended)
2.Installing SDK Starter Package (SDK Manager):

Note that you need to refer to the SDK directory (In Windows OS, this called “set path”)
3.Installing ADT plugin for Eclipse:

Configuring Eclipse to work with SDK Manager
4.Using SDK Manager to add platforms and other components:

SDKs, documents, sample source codes, etc.
4
Android Basic Course
© 2012 University of Science – HCM City
.
Installing JDK



Ex:

The installation directory is “c:\Program Files\Java\”

The JDK folder’s path is “c:\Program Files\Java\jdk1.6.0_17”
5
Android Basic Course
© 2012 University of Science – HCM City

.
Installing Eclipse Editor



Ex:

The installation directory is “d:\Program Files\”

The Eclipse folder’s path is “d:\Program Files\eclipse\”

At the first time launching Eclipse, you must select a workspace folder to store your projects.

Ex: The workspace folder is “d:\Program Files\eclipse\workspace\”

You can change workspace folder at any time you want.

Ex: File > Switch workspace > Other…
6
Android Basic Course
© 2012 University of Science – HCM City
.
Installing SDK starter package (SDK Manager)



Ex:

The installation directory is “d:\Program Files\Android\”


The SDK folder’s path is “d:\Program Files\Android\android-sdk-windows\”
7
Android Basic Course
© 2012 University of Science – HCM City
.
Installing ADT plugin for Eclipse

/>•
Start Eclipse, then select Help > Install New Software

Click Add, in the top-right corner.

In the Add Repository dialog that appears, enter "ADT Plugin" for the
Name
and the following URL for the
Location:

/>•
Click OK

Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).

In the Available Software dialog, select the checkbox next to Developer Tools and click Next.

In the next window, you'll see a list of the tools to be downloaded. Click Next.

Read and accept the license agreements, then click Finish.

Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.


When the installation completes, restart Eclipse
8
Android Basic Course
© 2012 University of Science – HCM City
.
Updating the ADT Plugin

Want to update the ADT plugin, see more :


9
Android Basic Course
© 2012 University of Science – HCM City
.
Installing ADT plugin for Eclipse
10
Android Basic Course
© 2012 University of Science – HCM City
.
Configuring Eclipse to work with SDK Manager

Start Eclipse, then Select Window > Preferences to open the Preferences panel (Mac OS X:
Eclipse > Preferences).

Select Android from the left panel.

You may see a dialog asking whether you want to send usage statistics to Google. If so, make your
choice and click Proceed. You cannot continue with this procedure until you click Proceed.

For the

SDK Location
in the main panel, click Browse and locate your downloaded SDK
directory.

Click Apply, then OK.
11
Android Basic Course
© 2012 University of Science – HCM City
.
Configuring Eclipse to work with SDK Manager
12
Android Basic Course
© 2012 University of Science – HCM City
.
Getting to know Android SDK tools

SDK Manager is used for adding platforms and other components.

Start Eclipse, then Select Android SDK Manager

Or launch SDK Manager.exe in Android SDK folder

AVD (Android Virtual Device) Manager is used for creating emulators corresponding to the
selected platforms.

Start Eclipse, then Select AVD Manager

Or launch AVD Manager.exe in Android SDK folder
13
Android Basic Course

© 2012 University of Science – HCM City
.
Using SDK Manager to add platforms and other components
14
Android Basic Course
© 2012 University of Science – HCM City
.
Using AVD Manager to create a new emulator
15
Android Basic Course
© 2012 University of Science – HCM City
.
Testing your development environment

If above things are be ready-to-work. You will run the
HelloWorld Application successfully.

http://
developer.android.com/resources/tutorials/hello-world.ht
ml

16
Android Basic Course
© 2012 University of Science – HCM City
.
Getting to know project structure
contains java source files
is generated when res folder is modified
is selected platform to build the application
is application package that will be installed on

emulators or real devices
are image resources
describes UI components
describes string constant values
is an application configuration file
17
Android Basic Course
© 2012 University of Science – HCM City
.
Getting to know how to switch platform

Right click the project root, then select Properties > Android > select the platform you want.
18
Android Basic Course
© 2012 University of Science – HCM City
.
Getting to know how to run with the default emulator

Run application with the default emulator

Right click project, then select Run As > Android Application
19
Android Basic Course
© 2012 University of Science – HCM City
.
Getting to know how to run with the specified emulator

Run application with the specified emulator

Right click project, then select Run As > Run Configurations… >

select the specified emulator
20
Android Basic Course
© 2012 University of Science – HCM City
.
Getting to know how to run with the specified emulator
21
Android Basic Course
© 2012 University of Science – HCM City
.
Getting to know DDMS tools

The ADT plug-in in Eclipse provides some useful tools to control your Android Emulator. In
Eclipse, click on the Open Perspective button and select DDMS or select Other…/DDMS.
22
Android Basic Course
© 2012 University of Science – HCM City
.
Overview DDMS Tools
23
Android Basic Course
© 2012 University of Science – HCM City
.
Overview DDMS Tools
24
Android Basic Course
© 2012 University of Science – HCM City
.
Getting to know how to debug with the default emulator
25


Debug application with the default emulator

Right click project, then select Debug As > Android Application

Select Yes to open Debug Perspective

×