chapter 2 setting up for development - ksu web...

46
Introduction to Android Application Development, Android Essentials, Fifth Edition Chapter 2 Setting Up for Development

Upload: trankhue

Post on 20-May-2018

233 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Introduction to Android Application Development, Android Essentials,

Fifth Edition

Chapter 2

Setting Up for Development

Page 2: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Chapter 2 Overview

Learn how to set up our Android development

environment

Look at many of the tools provided with the

Android SDK

Review the Android SDK License Agreement

Learn about many important SDK packages

Look at the sample applications available with the

SDK

Page 3: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Configuring Your Development

Environment

Android SDK compatible with Windows,

Macintosh, or Linux systems

Installation requirements for using this book:

– Java Development Kit (JDK), Version 7

• http://www.oracle.com/technetwork/java/javase/d

ownloads/index.html

– Android Studio (includes the Android SDK)

• http://d.android.com/sdk/index.html

Page 4: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Included with Android Studio

Android Studio

– SDK tools

– Platform tools

– The latest Android platform

– The latest Android system image for the

emulator

Page 5: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Alternative Compatible Java IDE

IntelliJ IDEA

– Community Edition

– Ultimate Edition

Page 6: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Alternative Configurations

(Cont’d)

When using other IDEs:

– Command-line tools

• http://d.android.com/tools/projects/projects-

cmdline.html

– Debugging

• http://d.android.com/tools/debugging/debugging-

projects-cmdline.html

– Testing

• http://d.android.com/tools/testing/testing_otheride

.html

Page 7: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Basic Installation Process

1. Download and install the appropriate JDK.

2. Download and install or unzip the appropriate

Android Studio package for your Operating

System.

3. Launch Android Studio and use the Android SDK

Manager to download and install specific Android

platform versions and other components.

4. Install appropriate USB drivers for device

debugging, if necessary.

5. Configure your device(s) for debugging.

6. Start developing.

Page 8: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Basic Installation Process

Page 9: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Configuring Your Operating

System for Device Debugging

To install and debug on real devices:

– Configure OS to access device via USB

– Mac OS

• May work without any configuration

– Windows

• Requires appropriate USB driver

• http://d.android.com/sdk/win-usb.html

– Linux

• Requires additional steps

• http://d.android.com/tools/device.html

Page 10: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Configuring Your OS for Device

Debugging (Cont’d)

Page 11: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Configuring Android Hardware for

Debugging

Devices with Android 4.2+ have debugging

disabled by default.

– This requires enabling Developer Options.

1. From the Home screen, choose All Apps →

Settings → About Phone (or About

Tablet).

2. Scroll down to Build Number.

3. Press Build Number seven times to unlock

Developer Options.

Page 12: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Configuring Android Hardware for

Debugging (Cont’d)

To install our own applications, configure our device to install from Unknown sources.

1. From Home → All Apps → Settings →

Security.

2. Enable (check) Unknown sources.

– Skipping this step prevents us from installing

our apps to our own device.

Page 13: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Configuring Android Hardware for

Debugging (Cont’d)

Page 14: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Configuring Android Hardware for

Debugging (Cont’d)

Enable some Developer Options settings.

– From Home → All Apps → Settings →

Developer options

• Then enable USB debugging.

Page 15: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Configuring Android Hardware for

Debugging (Cont’d)

Page 16: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Upgrading Android Studio and the

Android SDK

To stay up-to-date with the latest advancements:

– Upgrade from time to time

Updates include:

– New, updated, or removed features

– Package name changes

– Updated tools

– Essential documents

• Overview of Changes

• API Diff Report

• Release Notes

– See http://d.android.com/sdk/installing/adding-packages.html

Page 17: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Problems with Android Studio and

the Android SDK

There may be bugs!

– Find open issues and their status at the Android

project’s Issue Tracker website.

– Submit new issues for review.

– Issue tracker website:

• https://code.google.com/p/android/issues/list

– To report bugs or defects for Android Dev team:

• http://source.android.com/source/report-bugs.html

– Learn more about the bug-fixing process:

• http://source.android.com/source/life-of-a-bug.html

Page 18: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Exploring the Android SDK

Android SDK major components:

– Android SDK Platform by version

– Platform tools

– SDK Build Tools

– System images

– Google APIs

– Sources for Android SDK

– Extras

– Sample applications

Page 19: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

The Android SDK License

Agreement

Before downloading the SDK, you must agree to

the Android SDK License Agreement.

– This agreement is between you and Google.

– Make sure that you understand this license even

if someone else has accepted the agreement on

your behalf!

Page 20: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

The Android SDK License

Agreement (Cont’d)

Rights granted:

– Google grants you a limited, worldwide, royalty-

free, nonassignable, and nonexclusive license

to use the SDK solely to develop applications

for the Android platform.

– Google still holds all copyrights and intellectual

property rights to the SDK.

– Google does not grant permission to use any of

its brands, logos, or trade names.

– You will not remove any copyright notices

therein.

Page 21: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

The Android SDK License

Agreement (Cont’d)

SDK usage:

– You may only develop Android applications with

the SDK.

• You may not make derivative works from the

SDK or distribute the SDK on any device.

• You may not distribute part of the SDK with

other software.

Page 22: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

The Android SDK License

Agreement (Cont’d)

SDK changes and backward compatibility:

– Google may change the Android SDK at any

time without notice and without regard to

backward compatibility.

• Early APIs had frequent changes, but recent

releases are reasonably stable.

• Each SDK update does affect at least a small

number of apps.

– Updating your application is your own

responsibility.

Page 23: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

The Android SDK License

Agreement (Cont’d)

Android application developer rights:

– You retain all rights to any Android software you

develop with the SDK, including intellectual

property rights.

– You also retain all responsibility for your own

work.

Page 24: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

The Android SDK License

Agreement (Cont’d)

Android application privacy requirements:

– You agree that your application will protect the

privacy and legal rights of your users.

– If your app accesses personal and private info,

you must provide adequate privacy notice and

keep the data stored securely. These include

usernames, passwords, and so on.

– Privacy laws and regulations vary by user

location.

• You are solely responsible for managing this

data appropriately.

Page 25: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

The Android SDK License

Agreement (Cont’d)

Android application malware requirements:

– You are responsible for all applications you

develop.

– You agree not to write disruptive applications or

malware.

– You are solely responsible for all data

transmitted through your application.

Page 26: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

The Android SDK License

Agreement (Cont’d)

Additional terms for specific Google APIs:

– Use of APIs such as Google Maps Android API is

subject to further Terms of Service.

• You must agree to these additional terms before

using those specific APIs.

• You must always include the copyright notice,

too.

– Other API terms include Gmail, Blogger, Google

Calendar, and YouTube.

• Your application’s usage is limited to accessing

those to which your user has explicitly granted

permission.

Page 27: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

The Android SDK License

Agreement (Cont’d)

Develop at your own risk!

– Any harm that comes from developing with the

Android SDK is your own fault and not Google’s.

Page 28: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Reading the Android SDK

Documentation

Read locally or online:

– Online at http://d.android.com/index.html

Page 29: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Reading the Android SDK

Documentation (Cont’d)

Page 30: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Exploring the Core Android

Application Framework

Which file comprises the Android framework?

– android.jar

Page 31: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Important Packages in the

Android SDK

Top-Level Package Name Description

android.* Android application fundamentals

dalvik.* Dalvik virtual machine support classes

java.* Core classes and familiar generic utilities

javax.* Encryption support

junit.* Unit-testing support

org.apache.http.* HTTP protocol support

org.json JSON support

org.w3c.dom W3C DOM XML and HTML support

org.xml.* SAX support for XML

org.xmlpull.* High-performance XML pull parsing

Page 32: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Popular Third-Party Android APIs

Available outside the core Android SDK

Installed separately

Some are from Google, others from device

manufacturers and other providers

Page 33: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Popular Third-Party Android APIs

(Cont’d)

Android Support Library

Google Mobile Ads SDK (com.google.android.gms.ads.*)

Google Analytics SDK for Android (com.google.android.gms.analytics.*)

Android Cloud Messaging for Android (GCM) (com.google.android.gms.gcm)

Google App Indexing (com.google.android.gms.appindexing)

Google App Invites (com.google.android.gms.appinvite)

Google Play Game Services (com.google.android.gms.games)

Google Fit (com.google.android.gms.fitness)

Page 34: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Exploring the Core Android Tools

Android Studio

– Where you spend most of your time developing

your apps

– Provides wizards for creating, debugging, and

deploying Android apps

– Several buttons available on the toolbar for

performing helpful actions

Page 35: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Android Studio

Launch the Android Virtual Device Manager

Launch the Android SDK Manager

Launch the Android Device Monitor

Page 36: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Android Studio (Cont’d)

Page 37: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Android SDK and AVD Managers

The first Android toolbar icon launches the

Android Virtual Device Manager.

The second Android toolbar icon launches the

Android SDK Manager.

Page 38: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Android SDK and AVD Managers

(Cont’d)

Page 39: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Android SDK and AVD Managers

(Cont’d)

Page 40: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Android SDK and AVD Managers

(Cont’d)

Page 41: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Android Emulator

Helpful tool used for designing and developing

Android applications

Runs on your computer

Behaves like a real device

Load Android applications into the emulator to test

and debug them

Generic device, not tied to any one specific

configuration

Valuable, but should not be used as a replacement

for testing on actual target devices

Page 42: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Android Emulator (Cont’d)

Page 43: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Android Emulator (Cont’d)

Page 44: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Exploring the Android Sample

Applications

Demo applications are not provided as part of the Android

SDK by default.

– Android Studio provides a dialog for importing the sample

applications—from GitHub—as a project.

Android Studio sample applications code categories to

investigate:

– Getting started

– Background

– Input

– Media

– Connectivity

– Notification

– Wearable

Page 45: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

Chapter 2 Summary

We have learned how to install and configure

the tools for Android development.

– JDK, SDK, ADT Bundle

We have explored many of the tools provided

with the Android SDK.

We have reviewed the Android SDK License

Agreement.

We have learned about important SDK

packages.

We have perused the sample applications

provided with the SDK.

Page 46: Chapter 2 Setting Up for Development - KSU Web …ksuweb.kennesaw.edu/~mkang9/teaching/CS7455/CH02.pdfChapter 2 Setting Up for Development . ... • ... Press Build Number seven times

References and More Information

Google’s Android Developers Guide:

– http://d.android.com/guide/components/index.html

Android SDK download site:

– http://d.android.com/sdk/index.html

Android SDK License Agreement:

– http://d.android.com/sdk/terms.html

The Java Platform, Standard Edition:

– http://www.oracle.com/technetwork/java/javase/overview/index.html

JetBrains:

– https://www.jetbrains.com/

Android Developer Tools:

– https://developer.android.com/tools/help/adt.html

The Eclipse Project:

– http://www.eclipse.org