SlideShare a Scribd company logo
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Android Programming: Installation,
Setup, and Getting Started
Originals of Slides and Source Code for Examples:
http://www.coreservlets.com/android-tutorial/
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
For live Android training, please see courses
at http://courses.coreservlets.com/.
Taught by the author of Core Servlets and JSP, More
Servlets and JSP, and this Android tutorial. Available at
public venues, or customized versions can be held
on-site at your organization.
• Courses developed and taught by Marty Hall
– JSF 2, PrimeFaces, servlets/JSP, Ajax, jQuery, Android development, Java 6 or 7 programming, custom mix of topics
– Ajax courses can concentrate on 1 library (jQuery, Prototype/Scriptaculous, Ext-JS, Dojo, etc.) or survey several
• Courses developed and taught by coreservlets.com experts (edited by Marty)
– Spring, Hibernate/JPA, EJB3, GWT, Hadoop, SOAP-based and RESTful Web Services
Contact hall@coreservlets.com for details
Topics in This Section
• Installing the Software and Documentation
– Java 6
– Eclipse
– Android SDK base
– Eclipse ADT Plugin
– Updated SDK components
– AVD (Android Virtual Device)
• Running Apps
– Import and test an existing app
• Run on emulator
– Create and test a new app
• Run on emulator
– Seeing standard output in the DDMS
– Deploy app to USB-connected Android device4
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Installing the Software
and Documentation
JDK for Java SE 6
• Overview
– Use Java 6 (aka JDK 1.6)
• Java 5 supported only by older Android versions
• Java 7 can technically be used, but new Java 7 features
not supported
– For PC, Linux, Solaris, follow directions at
http://www.oracle.com/technetwork/java/javase/downloads/
• Get JDK, not just JRE
• Get SE (Standard Edition), not EE or Micro Edition
• Don’t get version with the NetBeans IDE
– For MacOS, Java is preinstalled & updated automatically
6
Installing Java SE 6
• Install Java 6 JDK
– http://www.oracle.com/technetwork/java/javase/downloads/
• Scroll down for Java SE 6
Use this version. The “JDK – Java
Development Kit” includes compiler for
.java files, whereas the “JRE – Java
Runtime Environment” is only for
executing prebuilt .class files.
This tutorial uses Eclipse,
so do not use this link.
As of summer 2012, there
is no NetBeans plugin for
Android development. So,
Eclipse is strongly
recommended even if you
normally use NetBeans for
Java development.
However, IntelliJ IDEA has
Android support: see
http://www.jetbrains.com/
idea/features/
google_android.html
After downloading, run installer and accept all defaults.
Eclipse
• Overview
– Eclipse is a free open source IDE (Integrated
Development Environment). Support for Java, HTML,
CSS, JavaScript, C++, PHP, and more.
– Google has free Eclipse plugin to integrate with the
Android SDK.
• Features
– General
• Checks your syntax as you type
• Automatically compiles every time you save file
• Refactoring, debugging, templates for common tasks, etc.
– Android-specific
• Deploy apps to Android emulator
• Configure virtual environments
• Drag-and-drop GUI builder8
Installing Eclipse
• Go to eclipse.org, click on “Downloads”
– Results in
http://eclipse.org/downloads/
– Can use either “for Java” or
“for Java EE”.
• I use EE version since I also use Eclipse for Web apps.
– Latest version (3.7 – Indigo) recommended.
• Previous version (3.6 – Helios) still supported
• Older versions (3.5 and earlier) not supported
9
Running Eclipse
• Unzip the downloaded file (no installer!)
– Call the folder you unzip into “installDir”
• Double click eclipse.exe
– From installDir/bin
• Click on
“Workbench” icon
– Next time you bring
up Eclipse, it will
come up in workbench automatically
• Shortcut
– Many developers put Eclipse link on their desktop
• R-click eclipse.exe, Copy, then go to desktop, R-click, and
Paste Shortcut (not just Paste!)
The Android SDK
• Overview
– Android-specific libraries
– Dalvik (Android virtual machine) compiler
– Android emulator (to run without physical device)
– DDMS debugging environment
• Documentation
– Installation
• http://developer.android.com/sdk/installing/index.html
– Developer’s Guide
• http://developer.android.com/guide/components/index.html
– JavaDoc (API Reference)
• http://developer.android.com/reference/classes.html
– Tutorials and articles
• http://developer.android.com/resources/index.html11
Bookmark these URLs!
Installing the Android SDK
• Download and run installer
– From http://developer.android.com/sdk/
• I install in C:android-sdk
– Sets up basic SDK, but omits many components
• Detailed instructions
– http://developer.android.com/sdk/installing/index.html
• Postponed step
– After installing Eclipse plugin, we will run the Android
SDK Manager to get important missing components
• Easiest to do from Eclipse. See upcoming slide after
Eclipse ADT installation.
12
Eclipse ADT Plugin
• Overview
– ADT (Android Development Tools) provides many
useful features accessible directly in Eclipse
• Integration between Eclipse & Android command-line tools
• Drag-and-drop GUI builder
• Many development and debugging aids
• Detailed installation instructions
– http://developer.android.com/sdk/installing/
installing-adt.html
• More details
– http://developer.android.com/sdk/eclipse-adt.html
13
Installing Eclipse ADT
• Steps
– Start Eclipse
– Help  Install New Software …
– Click “Add” in upper-right
– In Add Repository, for Name enter “ADT Plugin” and for
Location enter https://dl-ssl.google.com/android/eclipse/
– Click OK, select checkbox
next to Developer Tools, Next,
see packages to be installed,
accept license, Finish.
Restart Eclipse if asked.
– Run Android SDK Manager
• Should be prompted; if not,
Windows  Android SDK Manager
See next slide for details
14
Updating SDK
Components
• Run Android SDK manager
– Window  Android SDK Manager
• Probably prompted automatically after installing ADT
plugin and restarting Eclipse
– Select all entries, except that you can omit Android
versions older than 2.2
• Click “Install n packages”
• Runs for a long time
• Detailed instructions
– http://developer.android.com/
sdk/installing/adding-packages.html
15
Android Virtual Devices (AVDs)
• Overview
– An AVD (Android Virtual Device) is an Android Emulator
configuration that lets you model an actual device by defining
hardware and software options
• Idea
– Define several AVDs at different
Android API levels to test against.
At least two:
• Newest version (e.g., 4.1 – Jelly Bean)
• Most common version (2.3.3 as of 2012)
– To see statistics for versions of currently used Android devices, see
http://developer.android.com/about/dashboards/index.html
• Detailed instructions
– http://developer.android.com/guide/developing/devices/
managing-avds.html16
Android Version Popularity as of Summer 2012
Defining an AVD
• Defining
– Window  AVD Manager
– Click on “New” at top. Choose name (arbitrary) and
options. You can (should!) create multiple AVDs.
• Options
– Target (i.e., target API version)
• 4.1 to test tablet and new features
• 2.3.3 to test most common phones
– SD Card size
• Can be omitted. Or, choose middle
of the road value, e.g., 4 GB
– Skin
• Use default for the target you chose
17
Configuring Eclipse ADT
• Set SDK Location
– Window  Preferences  Android
– Click Browse and point at place you installed the SDK
• Optional: disable sending stats to Google
– Window  Preferences  Android  Usage Stats
18
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Running Apps on
Emulator
Big Ideas
• Running apps
– Soon, you want to learn how to write your own apps. First,
however, we will practice running existing apps.
• Ways to run
– Covered here
• On the Android Emulator. Deploy directly from Eclipse.
– During development, do your normal testing here
• On an Android device. Deploy from your PC via USB.
– Other options covered online
• On an Android device. Deploy from a Web site.
• On an Android device. Deploy via email.
• On and Android device. Deploy from the Android Market
• Writing apps
– Covered in later tutorial sections. That is the fun part!
20
Running the HelloAndroid App
in Emulator
• HelloAndroid
– Super-simple app to test deployment and execution steps.
• For students in live classes, this project is already in your
Eclipse workspace.
• For online readers, download project from the Getting Started
section of Android tutorial and import into Eclipse.
– http://www.coreservlets.com/android-tutorial/
• Steps to run it
– Import it if necessary
• File  General  Existing Projects…
– R-click on project on L side of Eclipse
– Run As  Android Application
• Long wait while emulator initializes
• Do not close emulator when done
– Next time, app will come up much faster
21
HelloAndroid: Result
22 Code will be discussed in next tutorial section.
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Making Your Own
Android App
Making Your Own Android App:
Basics
• Idea
– When you create a new app, it has simple “Hello World”
functionality built in.
• So, you can create and test an app without knowing
syntax (which is not discussed until next tutorial section)
• Steps
– File  New  Project  Android 
Android Application Project
• Next time you can do File  New 
Android Application Project
– Fill in options as shown on next pages
– Run new project as shown previously
• R-click  Run As  Android Application
24
New Android App:
Setting Project Options (Pg. 1)
• New Android Project Settings: Page 1
– Application Name
• Shown in Play Store and Settings  Manage Application List. Usually same as
Project Name.
– Project Name
• Eclipse project name. Follow naming convention you use for Eclipse. Not used
elsewhere.
– Package name
• Apps on a particular Android device must have unique packages, so use
com.yourCompany.project
– Build SDK
• The Android version used to build/compile your project. This can be any version (e.g.,
the most recent), but the safest option is to make it match the minimum SDK below.
– Minimum Required SDK
• The Android version that you want to run on. For most phone apps, choose 2.3.3,
since that is the most common version in use worldwide. For learning new features,
use latest version (4.1 as of summer 2012).
• The safest option is to use a number to match Build SDK. Summarized in Eclipse
dialog, but for details, see http://developer.android.com/guide/topics/manifest/
uses-sdk-element.html#ApiLevels
25
New Android App:
Setting Project Options (Pg. 1)
26
Eclipse project name
Package. Use naming convention
to ensure uniqueness
Android version used to compile your project
Android version that you want to run on
Usually number corresponding to Build SDK
New Android App:
Configure Launcher Icon
• Purpose
– To choose the picture displayed on the Android device,
that, when clicked, launches the app.
• Defaults
– Use defaults for development
and testing. Just press “Next”.
27
New Android App:
Create Activity
• Choose “BlankActivity”
– The Master/Detail option is used rarely,
and applies only to Android 3.0 or later.
28
New Android App:
New Blank Activity
• Options for Blank Activity
– Activity Name
• Name of “main” Java class. This is the class you will edit first.
Class name often corresponds to project name.
– Layout Name
• Base name of XML file in res/layout folder. Used to give layout to
app. Often just called “main”. Will be referred to in main Java
class with R.layout.layout_name.
– Navigation Type
• For now, leave this as “None”
– Hierarchical Parent
• Parent Activity (for when user
presses Up). Empty for now.
– Title
• Text that will be shown on Android
title bar.29
Running New App on Emulator
• Builtin functionality
– Newly created projects automatically have simple “Hello
World” behavior
• Execution steps
– Same as with any project
• R-click  Run As 
Android Applicaton
– Reminder: do not close
emulator after testing.
Emulator takes a long time
to start initially, but it is
relatively fast to deploy
a new or a changed
project to the emulator.
30
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Seeing Standard Output
in DDMS
DDMS Basics
• Idea
– DDMS (Dalvik Debug Monitor Service) is a tool that supports many things
• Simulate incoming calls in emulator
• Set GPS locations in emulator
• See print statements and runtime errors
• Set locations and take screenshots of actual Android device
• Simple usage now
– Start DDMS
• Window  Open Perspective
 Other  DDMS
• Once you do this once, you
can click on “DDMS” at
top right of Eclipse
• Click on “Java” to return to code
– See print statements
• Look in LogCat window at bottom
• Type part of output into Filter field to see specific output
32
DDMS Output (HelloAndroid)
• Code
– Put System.out.println
in main onCreate method
• See code in screenshot
on previous page
• onCreate and other syntax
discussed in next section
33
Output of System.out.println
Entered so it is easier to find specific output among
the many informational messages that emulator prints
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Running Apps on
Physical Android Device
Running Apps on Android
Device
• Idea
– The vast majority of your testing will be on Android emulator. But
sometimes you want to test on a physical phone or other Android device to
test compatibility and to use camera, GPS, contact list, etc.
• You first make a signed application package (YourApp.apk), then you have
various options for sending it to the phone
• Options
– Covered here
• Connect phone via USB, use Eclipse to deploy
– Can learn on your own
• Export signed app from Eclipse, use adb to install on phone
– See http://developer.android.com/tools/help/adb.html#move
• Other approaches
http://developer.android.com/tools/publishing/publishing_overview.html
– Submit app to Android marketplace
– Email apk file to email address of phone
– Deploy apk file to a Web site, then connect there from phone. Must set MIME type to
application/vnd.android.package-archive.
35
Deploying via USB Connection
• Prereq: install drivers for Android device
– Plug phone (or other Android device) into computer.
• Recent OS’s might find drivers automatically. If not, download
from device manufacturer. See list at
http://developer.android.com/tools/extras/oem-usb.html
– After installation, plug in phone, then go to android-dir/platform-tools/
and run “adb devices”. Your device should now be listed.
• Steps
– Android device
• Enable USB debugging
• Allow unknown sources
• Verify USB drivers are on computer
– http://developer.android.com/tools/extras/oem-usb.html
• Plug into computer via USB
– Eclipse
• R-click app, Run As  Android Application
– If emulator is open, will be given a choice of which device to deploy to.
If emulator not open, will deploy to physical device automatically.36
Configuring Android Device
• Enable USB debugging
– Settings  Applications 
Development
• Required: USB debugging
– Allows PC to send commands
via USB
• Optional: Stay awake
– Phone/device won’t sleep when
connected via USB
• Optional: Allow mock locations
– Let PC send fake GPS locations
• Allow unknown sources
– Settings  Applications 
Unknown sources
37
Running App on Device
• After running via Eclipse
– Will show automatically
• To run later
– Go to installed apps
– Tap new app
• Remember that the human
readable name (Application Name
from new Android Project wizard)
is shown, not the Java class name
– If you want to install update
• Uninstall old version first
– Settings  Applications  YourApp
 Uninstall
– Or long-press your app and choose
“Uninstall”
38
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Wrap-Up
Summary
• Install software
– Java 6, Eclipse, Android SDK, Eclipse ADT plugin
• Bookmark documentation
– Developer’s Guide and more at developer.android.com
• Update/configure software
– Set SDK location in Eclipse
– Get updated components via Android SDK Manager
– Define at least one AVD to run apps on emulator
• Run apps
– R-click project, Run As  Android Application
• On emulator (usually)
• On physical Android device (once in a while)
• Make new app
– File  New  Project  Android  Android Application Project
• See output of print statements
– In LogCat window of DDMS
40
© 2012 Marty Hall
Customized Java EE Training: http://courses.coreservlets.com/
Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Questions?
JSF 2, PrimeFaces, Java 7, Ajax, jQuery, Hadoop, RESTful Web Services, Android, Spring, Hibernate, Servlets, JSP, GWT, and other Java EE training.

More Related Content

PPTX
Migrating From Applets to Java Desktop Apps in JavaFX
PPTX
Desktop Applications with NetBeans
PPTX
Eclipse Vs Netbeans
PDF
Mobile developments at eXo
PPTX
Tech talks (Automation on Selenium Web Driver. How to begin & implement)
PDF
React.js alternatives modern web frameworks and lightweight java script libr...
PDF
Architecting iOS Project
Migrating From Applets to Java Desktop Apps in JavaFX
Desktop Applications with NetBeans
Eclipse Vs Netbeans
Mobile developments at eXo
Tech talks (Automation on Selenium Web Driver. How to begin & implement)
React.js alternatives modern web frameworks and lightweight java script libr...
Architecting iOS Project

What's hot (18)

PDF
p2, your savior or your achilles heel? Everything an Eclipse team needs to kn...
PPT
Introduction to android sessions new
PPT
Eclipse Plug-in Develompent Tips And Tricks
PDF
Java Desktop 2019
PPTX
OpenJFX on Android and Devices
PDF
Core Android
PDF
Java Builds with Maven and Ant
PDF
Introduction to android
PDF
Java is evolving rapidly: Maven helps you staying on track
PDF
WebObjects Developer Tools
PDF
Java Framework comparison
PDF
Cordova Tutorial
PDF
Maven tutorial
PPTX
AFNetworking
PPTX
Log management (elk) for spring boot application
PDF
Lua on Steroids - EclipseCon NA 2012
PDF
Introduction to Selenium and WebDriver
PPTX
Apache Maven - eXo VN office presentation
p2, your savior or your achilles heel? Everything an Eclipse team needs to kn...
Introduction to android sessions new
Eclipse Plug-in Develompent Tips And Tricks
Java Desktop 2019
OpenJFX on Android and Devices
Core Android
Java Builds with Maven and Ant
Introduction to android
Java is evolving rapidly: Maven helps you staying on track
WebObjects Developer Tools
Java Framework comparison
Cordova Tutorial
Maven tutorial
AFNetworking
Log management (elk) for spring boot application
Lua on Steroids - EclipseCon NA 2012
Introduction to Selenium and WebDriver
Apache Maven - eXo VN office presentation
Ad

Viewers also liked (11)

PDF
Konsequenzen der Digitalisierung aufs Verkaufen / Jahrbuch Marketing 2012
PPTX
Creative Group Project (1)
PDF
Resume_Femina_0516
PDF
Insights Mood & Mind
PPT
MikroTIK DHCP Server
PPTX
Network Simulation using Mikrotik Router OS CHR (MUM Presentation)
PPTX
Task 7 evaluation
PDF
Class 6
PPTX
Geography of Pakistan
PDF
Why Are You Roadmapping?
PPTX
Lição 4 Esteja alerta e vigilante, Jesus voltará
Konsequenzen der Digitalisierung aufs Verkaufen / Jahrbuch Marketing 2012
Creative Group Project (1)
Resume_Femina_0516
Insights Mood & Mind
MikroTIK DHCP Server
Network Simulation using Mikrotik Router OS CHR (MUM Presentation)
Task 7 evaluation
Class 6
Geography of Pakistan
Why Are You Roadmapping?
Lição 4 Esteja alerta e vigilante, Jesus voltará
Ad

Similar to Android training in Noida (20)

PPTX
PPT
Webinar on Google Android SDK
PDF
01 04 - android set up and creating an android project
PPTX
03 Beginning Android Application Development
PPTX
Android
PPT
Getting started with android dev and test perspective
PPTX
Android installation guide
PPTX
Android development classes in chandigarh : Big Boxx Academy
PPT
Lec004 setting up for development
PPT
Android Application Development Using Java
PDF
Android programming-basics
PDF
ANDROID PPT 1.pdf
PPTX
Developing for Android-Types of Android Application
PDF
Android Development Tools and Installation
PPT
Android Application Development Environment Setup
PPTX
this is PPT for mobail application development
PPT
Industrial Training in Android Application
PPTX
01 introduction & setup - Android
PPTX
Android
PPTX
Android Basic
Webinar on Google Android SDK
01 04 - android set up and creating an android project
03 Beginning Android Application Development
Android
Getting started with android dev and test perspective
Android installation guide
Android development classes in chandigarh : Big Boxx Academy
Lec004 setting up for development
Android Application Development Using Java
Android programming-basics
ANDROID PPT 1.pdf
Developing for Android-Types of Android Application
Android Development Tools and Installation
Android Application Development Environment Setup
this is PPT for mobail application development
Industrial Training in Android Application
01 introduction & setup - Android
Android
Android Basic

Recently uploaded (20)

PPTX
Institutional Correction lecture only . . .
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Cell Types and Its function , kingdom of life
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
01-Introduction-to-Information-Management.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Pre independence Education in Inndia.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
master seminar digital applications in india
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
Institutional Correction lecture only . . .
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
O7-L3 Supply Chain Operations - ICLT Program
Cell Types and Its function , kingdom of life
human mycosis Human fungal infections are called human mycosis..pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
01-Introduction-to-Information-Management.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Pre independence Education in Inndia.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Week 4 Term 3 Study Techniques revisited.pptx
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
master seminar digital applications in india
O5-L3 Freight Transport Ops (International) V1.pdf

Android training in Noida

  • 1. © 2012 Marty Hall Customized Java EE Training: http://courses.coreservlets.com/ Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android. Developed and taught by well-known author and developer. At public venues or onsite at your location. Android Programming: Installation, Setup, and Getting Started Originals of Slides and Source Code for Examples: http://www.coreservlets.com/android-tutorial/ © 2012 Marty Hall Customized Java EE Training: http://courses.coreservlets.com/ Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android. Developed and taught by well-known author and developer. At public venues or onsite at your location. For live Android training, please see courses at http://courses.coreservlets.com/. Taught by the author of Core Servlets and JSP, More Servlets and JSP, and this Android tutorial. Available at public venues, or customized versions can be held on-site at your organization. • Courses developed and taught by Marty Hall – JSF 2, PrimeFaces, servlets/JSP, Ajax, jQuery, Android development, Java 6 or 7 programming, custom mix of topics – Ajax courses can concentrate on 1 library (jQuery, Prototype/Scriptaculous, Ext-JS, Dojo, etc.) or survey several • Courses developed and taught by coreservlets.com experts (edited by Marty) – Spring, Hibernate/JPA, EJB3, GWT, Hadoop, SOAP-based and RESTful Web Services Contact hall@coreservlets.com for details
  • 2. Topics in This Section • Installing the Software and Documentation – Java 6 – Eclipse – Android SDK base – Eclipse ADT Plugin – Updated SDK components – AVD (Android Virtual Device) • Running Apps – Import and test an existing app • Run on emulator – Create and test a new app • Run on emulator – Seeing standard output in the DDMS – Deploy app to USB-connected Android device4 © 2012 Marty Hall Customized Java EE Training: http://courses.coreservlets.com/ Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android. Developed and taught by well-known author and developer. At public venues or onsite at your location. Installing the Software and Documentation
  • 3. JDK for Java SE 6 • Overview – Use Java 6 (aka JDK 1.6) • Java 5 supported only by older Android versions • Java 7 can technically be used, but new Java 7 features not supported – For PC, Linux, Solaris, follow directions at http://www.oracle.com/technetwork/java/javase/downloads/ • Get JDK, not just JRE • Get SE (Standard Edition), not EE or Micro Edition • Don’t get version with the NetBeans IDE – For MacOS, Java is preinstalled & updated automatically 6 Installing Java SE 6 • Install Java 6 JDK – http://www.oracle.com/technetwork/java/javase/downloads/ • Scroll down for Java SE 6 Use this version. The “JDK – Java Development Kit” includes compiler for .java files, whereas the “JRE – Java Runtime Environment” is only for executing prebuilt .class files. This tutorial uses Eclipse, so do not use this link. As of summer 2012, there is no NetBeans plugin for Android development. So, Eclipse is strongly recommended even if you normally use NetBeans for Java development. However, IntelliJ IDEA has Android support: see http://www.jetbrains.com/ idea/features/ google_android.html After downloading, run installer and accept all defaults.
  • 4. Eclipse • Overview – Eclipse is a free open source IDE (Integrated Development Environment). Support for Java, HTML, CSS, JavaScript, C++, PHP, and more. – Google has free Eclipse plugin to integrate with the Android SDK. • Features – General • Checks your syntax as you type • Automatically compiles every time you save file • Refactoring, debugging, templates for common tasks, etc. – Android-specific • Deploy apps to Android emulator • Configure virtual environments • Drag-and-drop GUI builder8 Installing Eclipse • Go to eclipse.org, click on “Downloads” – Results in http://eclipse.org/downloads/ – Can use either “for Java” or “for Java EE”. • I use EE version since I also use Eclipse for Web apps. – Latest version (3.7 – Indigo) recommended. • Previous version (3.6 – Helios) still supported • Older versions (3.5 and earlier) not supported 9
  • 5. Running Eclipse • Unzip the downloaded file (no installer!) – Call the folder you unzip into “installDir” • Double click eclipse.exe – From installDir/bin • Click on “Workbench” icon – Next time you bring up Eclipse, it will come up in workbench automatically • Shortcut – Many developers put Eclipse link on their desktop • R-click eclipse.exe, Copy, then go to desktop, R-click, and Paste Shortcut (not just Paste!) The Android SDK • Overview – Android-specific libraries – Dalvik (Android virtual machine) compiler – Android emulator (to run without physical device) – DDMS debugging environment • Documentation – Installation • http://developer.android.com/sdk/installing/index.html – Developer’s Guide • http://developer.android.com/guide/components/index.html – JavaDoc (API Reference) • http://developer.android.com/reference/classes.html – Tutorials and articles • http://developer.android.com/resources/index.html11 Bookmark these URLs!
  • 6. Installing the Android SDK • Download and run installer – From http://developer.android.com/sdk/ • I install in C:android-sdk – Sets up basic SDK, but omits many components • Detailed instructions – http://developer.android.com/sdk/installing/index.html • Postponed step – After installing Eclipse plugin, we will run the Android SDK Manager to get important missing components • Easiest to do from Eclipse. See upcoming slide after Eclipse ADT installation. 12 Eclipse ADT Plugin • Overview – ADT (Android Development Tools) provides many useful features accessible directly in Eclipse • Integration between Eclipse & Android command-line tools • Drag-and-drop GUI builder • Many development and debugging aids • Detailed installation instructions – http://developer.android.com/sdk/installing/ installing-adt.html • More details – http://developer.android.com/sdk/eclipse-adt.html 13
  • 7. Installing Eclipse ADT • Steps – Start Eclipse – Help  Install New Software … – Click “Add” in upper-right – In Add Repository, for Name enter “ADT Plugin” and for Location enter https://dl-ssl.google.com/android/eclipse/ – Click OK, select checkbox next to Developer Tools, Next, see packages to be installed, accept license, Finish. Restart Eclipse if asked. – Run Android SDK Manager • Should be prompted; if not, Windows  Android SDK Manager See next slide for details 14 Updating SDK Components • Run Android SDK manager – Window  Android SDK Manager • Probably prompted automatically after installing ADT plugin and restarting Eclipse – Select all entries, except that you can omit Android versions older than 2.2 • Click “Install n packages” • Runs for a long time • Detailed instructions – http://developer.android.com/ sdk/installing/adding-packages.html 15
  • 8. Android Virtual Devices (AVDs) • Overview – An AVD (Android Virtual Device) is an Android Emulator configuration that lets you model an actual device by defining hardware and software options • Idea – Define several AVDs at different Android API levels to test against. At least two: • Newest version (e.g., 4.1 – Jelly Bean) • Most common version (2.3.3 as of 2012) – To see statistics for versions of currently used Android devices, see http://developer.android.com/about/dashboards/index.html • Detailed instructions – http://developer.android.com/guide/developing/devices/ managing-avds.html16 Android Version Popularity as of Summer 2012 Defining an AVD • Defining – Window  AVD Manager – Click on “New” at top. Choose name (arbitrary) and options. You can (should!) create multiple AVDs. • Options – Target (i.e., target API version) • 4.1 to test tablet and new features • 2.3.3 to test most common phones – SD Card size • Can be omitted. Or, choose middle of the road value, e.g., 4 GB – Skin • Use default for the target you chose 17
  • 9. Configuring Eclipse ADT • Set SDK Location – Window  Preferences  Android – Click Browse and point at place you installed the SDK • Optional: disable sending stats to Google – Window  Preferences  Android  Usage Stats 18 © 2012 Marty Hall Customized Java EE Training: http://courses.coreservlets.com/ Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android. Developed and taught by well-known author and developer. At public venues or onsite at your location. Running Apps on Emulator
  • 10. Big Ideas • Running apps – Soon, you want to learn how to write your own apps. First, however, we will practice running existing apps. • Ways to run – Covered here • On the Android Emulator. Deploy directly from Eclipse. – During development, do your normal testing here • On an Android device. Deploy from your PC via USB. – Other options covered online • On an Android device. Deploy from a Web site. • On an Android device. Deploy via email. • On and Android device. Deploy from the Android Market • Writing apps – Covered in later tutorial sections. That is the fun part! 20 Running the HelloAndroid App in Emulator • HelloAndroid – Super-simple app to test deployment and execution steps. • For students in live classes, this project is already in your Eclipse workspace. • For online readers, download project from the Getting Started section of Android tutorial and import into Eclipse. – http://www.coreservlets.com/android-tutorial/ • Steps to run it – Import it if necessary • File  General  Existing Projects… – R-click on project on L side of Eclipse – Run As  Android Application • Long wait while emulator initializes • Do not close emulator when done – Next time, app will come up much faster 21
  • 11. HelloAndroid: Result 22 Code will be discussed in next tutorial section. © 2012 Marty Hall Customized Java EE Training: http://courses.coreservlets.com/ Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android. Developed and taught by well-known author and developer. At public venues or onsite at your location. Making Your Own Android App
  • 12. Making Your Own Android App: Basics • Idea – When you create a new app, it has simple “Hello World” functionality built in. • So, you can create and test an app without knowing syntax (which is not discussed until next tutorial section) • Steps – File  New  Project  Android  Android Application Project • Next time you can do File  New  Android Application Project – Fill in options as shown on next pages – Run new project as shown previously • R-click  Run As  Android Application 24 New Android App: Setting Project Options (Pg. 1) • New Android Project Settings: Page 1 – Application Name • Shown in Play Store and Settings  Manage Application List. Usually same as Project Name. – Project Name • Eclipse project name. Follow naming convention you use for Eclipse. Not used elsewhere. – Package name • Apps on a particular Android device must have unique packages, so use com.yourCompany.project – Build SDK • The Android version used to build/compile your project. This can be any version (e.g., the most recent), but the safest option is to make it match the minimum SDK below. – Minimum Required SDK • The Android version that you want to run on. For most phone apps, choose 2.3.3, since that is the most common version in use worldwide. For learning new features, use latest version (4.1 as of summer 2012). • The safest option is to use a number to match Build SDK. Summarized in Eclipse dialog, but for details, see http://developer.android.com/guide/topics/manifest/ uses-sdk-element.html#ApiLevels 25
  • 13. New Android App: Setting Project Options (Pg. 1) 26 Eclipse project name Package. Use naming convention to ensure uniqueness Android version used to compile your project Android version that you want to run on Usually number corresponding to Build SDK New Android App: Configure Launcher Icon • Purpose – To choose the picture displayed on the Android device, that, when clicked, launches the app. • Defaults – Use defaults for development and testing. Just press “Next”. 27
  • 14. New Android App: Create Activity • Choose “BlankActivity” – The Master/Detail option is used rarely, and applies only to Android 3.0 or later. 28 New Android App: New Blank Activity • Options for Blank Activity – Activity Name • Name of “main” Java class. This is the class you will edit first. Class name often corresponds to project name. – Layout Name • Base name of XML file in res/layout folder. Used to give layout to app. Often just called “main”. Will be referred to in main Java class with R.layout.layout_name. – Navigation Type • For now, leave this as “None” – Hierarchical Parent • Parent Activity (for when user presses Up). Empty for now. – Title • Text that will be shown on Android title bar.29
  • 15. Running New App on Emulator • Builtin functionality – Newly created projects automatically have simple “Hello World” behavior • Execution steps – Same as with any project • R-click  Run As  Android Applicaton – Reminder: do not close emulator after testing. Emulator takes a long time to start initially, but it is relatively fast to deploy a new or a changed project to the emulator. 30 © 2012 Marty Hall Customized Java EE Training: http://courses.coreservlets.com/ Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android. Developed and taught by well-known author and developer. At public venues or onsite at your location. Seeing Standard Output in DDMS
  • 16. DDMS Basics • Idea – DDMS (Dalvik Debug Monitor Service) is a tool that supports many things • Simulate incoming calls in emulator • Set GPS locations in emulator • See print statements and runtime errors • Set locations and take screenshots of actual Android device • Simple usage now – Start DDMS • Window  Open Perspective  Other  DDMS • Once you do this once, you can click on “DDMS” at top right of Eclipse • Click on “Java” to return to code – See print statements • Look in LogCat window at bottom • Type part of output into Filter field to see specific output 32 DDMS Output (HelloAndroid) • Code – Put System.out.println in main onCreate method • See code in screenshot on previous page • onCreate and other syntax discussed in next section 33 Output of System.out.println Entered so it is easier to find specific output among the many informational messages that emulator prints
  • 17. © 2012 Marty Hall Customized Java EE Training: http://courses.coreservlets.com/ Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android. Developed and taught by well-known author and developer. At public venues or onsite at your location. Running Apps on Physical Android Device Running Apps on Android Device • Idea – The vast majority of your testing will be on Android emulator. But sometimes you want to test on a physical phone or other Android device to test compatibility and to use camera, GPS, contact list, etc. • You first make a signed application package (YourApp.apk), then you have various options for sending it to the phone • Options – Covered here • Connect phone via USB, use Eclipse to deploy – Can learn on your own • Export signed app from Eclipse, use adb to install on phone – See http://developer.android.com/tools/help/adb.html#move • Other approaches http://developer.android.com/tools/publishing/publishing_overview.html – Submit app to Android marketplace – Email apk file to email address of phone – Deploy apk file to a Web site, then connect there from phone. Must set MIME type to application/vnd.android.package-archive. 35
  • 18. Deploying via USB Connection • Prereq: install drivers for Android device – Plug phone (or other Android device) into computer. • Recent OS’s might find drivers automatically. If not, download from device manufacturer. See list at http://developer.android.com/tools/extras/oem-usb.html – After installation, plug in phone, then go to android-dir/platform-tools/ and run “adb devices”. Your device should now be listed. • Steps – Android device • Enable USB debugging • Allow unknown sources • Verify USB drivers are on computer – http://developer.android.com/tools/extras/oem-usb.html • Plug into computer via USB – Eclipse • R-click app, Run As  Android Application – If emulator is open, will be given a choice of which device to deploy to. If emulator not open, will deploy to physical device automatically.36 Configuring Android Device • Enable USB debugging – Settings  Applications  Development • Required: USB debugging – Allows PC to send commands via USB • Optional: Stay awake – Phone/device won’t sleep when connected via USB • Optional: Allow mock locations – Let PC send fake GPS locations • Allow unknown sources – Settings  Applications  Unknown sources 37
  • 19. Running App on Device • After running via Eclipse – Will show automatically • To run later – Go to installed apps – Tap new app • Remember that the human readable name (Application Name from new Android Project wizard) is shown, not the Java class name – If you want to install update • Uninstall old version first – Settings  Applications  YourApp  Uninstall – Or long-press your app and choose “Uninstall” 38 © 2012 Marty Hall Customized Java EE Training: http://courses.coreservlets.com/ Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android. Developed and taught by well-known author and developer. At public venues or onsite at your location. Wrap-Up
  • 20. Summary • Install software – Java 6, Eclipse, Android SDK, Eclipse ADT plugin • Bookmark documentation – Developer’s Guide and more at developer.android.com • Update/configure software – Set SDK location in Eclipse – Get updated components via Android SDK Manager – Define at least one AVD to run apps on emulator • Run apps – R-click project, Run As  Android Application • On emulator (usually) • On physical Android device (once in a while) • Make new app – File  New  Project  Android  Android Application Project • See output of print statements – In LogCat window of DDMS 40 © 2012 Marty Hall Customized Java EE Training: http://courses.coreservlets.com/ Java, JSF 2, PrimeFaces, Servlets, JSP, Ajax, jQuery, Spring, Hibernate, RESTful Web Services, Hadoop, Android. Developed and taught by well-known author and developer. At public venues or onsite at your location. Questions? JSF 2, PrimeFaces, Java 7, Ajax, jQuery, Hadoop, RESTful Web Services, Android, Spring, Hibernate, Servlets, JSP, GWT, and other Java EE training.