android 1: background kirk scott. 1.1 buzzwords 1.2 development software 1.3 getting started 1.4...

111
Android 1: Background Kirk Scott

Upload: mervyn-ray

Post on 30-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Android 1: Background

Kirk Scott

Page 2: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• 1.1 Buzzwords• 1.2 Development Software• 1.3 Getting Started• 1.4 Preliminaries to Trying to Make It Work

the First Time

Page 3: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• 1.5 Creating a New, Example Android Application Project in Eclipse

• 1.6 Creating a Virtual Device, an Emulator• 1.7 Running an App on the Emulator in Eclipse• 1.8 Running the Project on an Attached

Device Instead of an Emulator

Page 4: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

1.1 Buzzwords…

Page 5: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• The Android platform originated in a separate company

• It was acquired by Google• It is supported by the Open Handset Alliance

(OHA)• From a business perspective, Android is

distinguished by the fact that many vendors are cooperating to provide a non-proprietary development environment

Page 6: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Key components of this successful alliance are:• Hardware device manufacturers• Mobile service providers• Android/Google, which provides the basic

software operating and development environments

• Independent app developers marketing through the app store or other places

Page 7: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• The platform is based on:• A secure operating system, Linux• Virtual machines running on top of Linux

(known as Dalvik virtual machines)• A widely-known object-oriented language,

Java• A tested software development environment,

Eclipse

Page 8: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Proprietary vs. non-proprietary• Android is based on open source licensing• Developers do not have to pay fees to use the

development tool kit• The do not have to pay fees on the apps

developed with it• The app developer API includes everything that

a “native” programmer would have access to

Page 9: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• The theory is that there is a large potential market

• By opening up the environment, you increase the size of the pie for everyone

• Android is growing from phones to tablets to other devices

• The growth is being driven by the app market

Page 10: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Another useful aspect of the development environment:

• It comes with an emulator for handheld devices• This means that you can initially develop and

test code on a PC with the development environment installed

• You don’t literally have to develop on the handheld device

Page 11: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Emulation isn’t the be-all, end-all• The emulator is slow• The emulator can be problematic• The emulator may not fully model the

hardware device of interest• The reality is that you eventually have to test

and finish development on a hardware device if you expect to roll out the app on that device

Page 12: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• You may have heard of “Ice Cream Sandwich” (ICS) or Jellybean

• As of the writing of these overheads, these are the most recent versions of the Android SDK

• It is worthwhile to note that the latest versions essentially merge two strains in Android:

• Development for cell phones and development for tablets

Page 13: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• You may also be curious about how versions were named

• The different versions have been named after sweets in alphabetical order

• Here are the versions and names• 1.5, Cupcake• 1.6, Donut• 2.0/2.1, Eclair

Page 14: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• 2.2, Froyo• 2.3, Gingerbread• 3.0, Honecomb• 4.0, Ice Cream Sandwich• 4.1, Jellybean• Note that this list is more than just a historical

curiosity• As with any growing system, backwards compatibility

is an issue, and there are plenty of systems out there using earlier versions

Page 15: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

1.2 Development Software

Page 16: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• To start developing for Android you essentially need to download and install two pieces of software:

• The Java SDK• The Android Development Toolkit (ADT) bundle• The bundle includes Eclipse• It includes Android classes for development• It includes the emulator so that you can start to

learn development without access to an Android hardware device

Page 17: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• As with all growing and changing systems, documenting installation and use is hopeless

• As soon as you write something down, it’s out of date

• These overheads are designed for computer literate persons, in other words, computer science students

Page 18: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Entry points and some guidance are given• Persistence and a willingness to fiddle around

are required• Experience has shown that most students are

actually better at this than the teacher• For what it’s worth, these overheads were

created after installing Java v. 1.7.0_11 and Android v. 4.2 API level 17

Page 19: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Since Java was acquired by Oracle, the entry point for downloading Java is www.oracle.com

• On that Web page there is a link for downloads

• Under that heading you can find Java for developers

• Find the right SDK for your system and install it before installing the Android tools

Page 20: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• The highest level entry point for Android is www.android.com

• On this Web page you’ll find a link for developers or you can go directly to developer.android.com

• Find the ADT bundle which is right for your system and install it

• For the time being, just accept the defaults, whatever they might be

Page 21: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Virtually anything you might want to know about Android programming can be found at the developer’s Web site

• The site includes tutorials on app development

• It includes Java-like documentation of the packages and classes in the Android API

• It includes detailed technical information

Page 22: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• The problem is the eternal one:• There is too much information• The average programmer doesn’t know where

to start and can’t distinguish the essential from the interesting or the overwhelming

• The purpose of this set of overheads and those that may follow is to provide the barest guide to getting started

Page 23: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• There are two important principles at work here that kitchen-sink Web site and textbook authors seem to be unfamiliar with:

• 1. There are lots of things that you simply don’t have to be told about at the beginning

• There may come a time in the future when some overlooked items will be introduced, but until then, ignorance may not be bliss, but it’s necessary

Page 24: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• 2. There are lots of things where you will have to accept that they exist and learn how to use them at a minimal level without having any idea of how they work

• In other words, at the beginning you will be doing a lot of monkey work just to get the Android machinery to run a painfully simple app

• For the time being you will have to accept the machinery without explanation

Page 25: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

1.3 Getting Started

Page 26: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• The starting point for the following overheads is a successful installation of Java and the ADT bundle on your system

• Once the ADT is installed, your entry point into Android development will be Eclipse

• This isn’t really an introduction to Eclipse because I don’t have any pre-existing knowledge of how to use it

Page 27: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• However, given that Eclipse will be the development environment, it is possible to point out what is included with it when it is installed as part of the ADT bundle

• There is an Android SDK Manager tool• There is an Android Virtual Device Manager

tool• And there is a DDMS perspective

Page 28: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• The Android SDK Manager tool is represented in the Eclipse toolbar by a small, green Android icon

• It looks something like this

Page 29: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• The Android Virtual Device Manager tool is represented in the Eclipse toolbar by an icon with the Android robot half showing on the screen of a handheld device

• It’s located next to the Android SDK Manager tool

• It looks something like this

Page 30: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Off to the right on the tool bar there are two buttons

• One is labeled Java• The other is labeled DDMS• These are Eclipse perspectives• In other words, clicking one of these changes

what you are viewing in the Eclipse environment

Page 31: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• DDMS is Android related• It stands for Dalvik Debug Monitor Server• At the moment it’s too soon to give much

detail about the DDMS perspective except that it should be there after a successful installation

• As noted earlier, Dalvik is the name of the virtual machine that Android apps run on

Page 32: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• A screenshot of the Eclipse interface is shown on the following overhead

• Things come up tiny, but you may just be able to identify the tools and buttons

• The point is that Android things are included in the toolbar when you successfully install Eclipse as part of the bundle

• These tools are also available through the menu if the toolbar isn’t showing

Page 33: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 34: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• It’s not too soon to say something about the Android SDK Manager and the Android Virtual Device Manager

• A screenshot of the Android SDK Manager tool is shown on the following overhead

• The tool allows you to manage and update what is installed on your development machine

Page 35: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 36: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• A screenshot of the Android Virtual Device Manager tool is shown on the overhead following the next one

• At the moment the details are unimportant• We will be using the tool soon enough

Page 37: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• It is presented now because it emphasizes the idea that you can develop on an emulator

• The “virtual device” manager is that part of the environment which makes it possible to define and manage emulators for the many different kinds of handheld devices there are

• Even though emulation isn’t perfect, it’s a very helpful part of a development environment that you can try out an application on different devices in this way

Page 38: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 39: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

1.4 Preliminaries to Trying to Make It Work the First Time

Page 40: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Preliminary Crying

• Trying to make things work the first time is where a miracle is supposed to occur

• It’s not realistic to expect any set of instructions or screen shots to preview exactly what you will have to do to make things happen or to anticipate all of the problems that might occur along the way

Page 41: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Your hardware is probably different• Your installation of the software may be

different• I initially had mismatches between 32 bit and

64 bit software for Java and the Android SDK which I had to resolve

• It is possible that you will be using different versions from what I’ve used

Page 42: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• I had one completely unexpected problem with no hope of solving it except a random Web search

• The Web search succeeded• I had other problems where there was no

apparent solution, and I finally got things to work by restarting, randomly trying different parameters, etc.

Page 43: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• I initially worked on the initial example app over the course of 24 hours, probably 8-12 actually messing with Android

• I tried to get the initial example app going about 10 times

• I literally had success 2 of those times

Page 44: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• You should be prepared for failure and frustration

• You will have to be flexible, analytical, and persistent

• Aside from everything else, you will have to be patient

Page 45: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• I am pretty sure that most of my problems came from the fact that starting the emulator is painfully slow

• It is unbelievable how slow this is on an up-to-date, reasonably powerful machine with a reasonable amount of memory

• The point is that if you try to launch an app on an emulator that hasn’t yet fully started, the app certainly won’t run

Page 46: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• On the following overheads a general overview is given of what is involved in getting a sample application to work—without even looking at its code, how it works, what Android features it is making use of or depends on

• This is the initial monkey work mentioned at the beginning of the overheads

Page 47: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• I will be basing these overheads on the initial example app that is given in the tutorial on the Android developer’s Web site

• This is a bit of a cop out, but if you discover that something in the overheads doesn’t seem to work, try working looking at the information in the tutorial

Page 48: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Workspaces

• These overheads don’t give any specific information about workspaces

• However, the Eclipse environment organizes projects and packages in workspaces

• At some point during installation, set-up, or initial run, you will probably be given the option to either accept a default folder as a workspace or to specify your own

Page 49: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Needless to say, this is important for general reasons:

• It’s handy to know where things are being stored

• At various points along the way, it will be useful to recall that information

Page 50: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

The Android Demos/Tutorials in Eclipse

• If your installation is like mine, when you start up Eclipse the first screen that will be shown is an entry point into the demos/tutorials

• This is shown on the following overhead• The first step, “Build Your First App” is the stage

we’re at• This is where to go if you start getting bogged

down in these overheads and you want an alternative presentation

Page 51: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 52: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

1.5 Creating a New, Example Android Application Project in Eclipse

Page 53: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Go to the Eclipse menu which is showing above the Welcome screen

• Take the option File, New, Android Application Project

• The result of this is shown in the screenshot on the following overhead

Page 54: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 55: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• In the first box, type in the following:• My First App• If Android hasn’t changed or replaced this

initial example, the other boxes will auto-complete as shown in the following screenshot

• (If not, this is the first stage where you will have to go fish)

Page 56: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 57: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• If things auto-completed as hoped, then you click the Next > button

• I will not show the next screenshots for the wizard• Just keep on accepting the defaults and taking

Next until your reach the Finish option• Notice how this is an area where you’re just doing

monkey work• God knows what all of the options mean at this

point

Page 58: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Once you click finish “things will happen”• They will tend to happen slowly• I have a reasonably powerful machine and it

takes things a while to happen• There is a progress bar at the bottom which

gives you some indication of what’s going on

Page 59: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• The initial Welcome screen may remain visible• If so, it covers up what has happened• Minimize anything in the way, and with luck,

what you will see in the Eclipse environment will look more or less like the screenshot on the following overhead

Page 60: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 61: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• There are several things to notice in this screenshot

• The simplest and most reassuring is that if you can actually read the fine print, you will see that My First App is a Hello World app

• Obviously you’re not looking at code

Page 62: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• If you look at the name of the file that is being shown by default, you’ll see that it’s an XML file

• What you’re seeing is a representation of the output of the app

• On the other hand, also be clear that this is the development environment

• What you’re seeing is not the emulator

Page 63: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Less reassuring is that this screenshot of the editor doesn’t look quite like the one given earlier

• It doesn’t show the tools mentioned earlier• This is an accident, but it’s something that may

happen to you• The toolbar has simply disappeared• You can cause it to appear again or you can

access the tools through the menu

Page 64: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

1.6 Creating a Virtual Device, an Emulator

Page 65: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Running the Project on a Virtual Device, an Emulator

• If you want to run the project using the emulator, you need to use the Android Virtual Device Manager to create a new virtual device

• If you take the Android Virtual Device Manager tool (or menu option) you should arrive at something similar to the screenshot shown on the following overhead

Page 66: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 67: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Click the New button to create an Android Virtual Device

• The window shown in the screenshot on the following overhead comes up

Page 68: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 69: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• It’s shown on the following overhead with the drop down list for Device expanded

Page 70: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 71: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• I tried using various devices• For initial test purposes I finally settled on the

device at the bottom of the list• My theory was that the emulators for older,

simpler devices might be more stable than emulators for the latest kinds of devices

• On the following overhead the form is shown filled out with representative values for that simple device

Page 72: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 73: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Another mystery:• Certain reference sources waffle on the

desirability of the Snapshot option• If you do select Snapshot and then make other

changes, you may have troubles later• Without Snapshot things might run more

slowly, but again, for the first time, try it without Snapshot

Page 74: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Warning

• Here is an example of what can go wrong• I also tried doing this with the largest Nexus device,

the tablet• The memory option defaulted to a RAM value of

1024• I have a relatively recent machine with a fair amount

of memory and unremarkable software installed on it

• Unfortunately, when I continued with that value of 1024, I got a mystery error

Page 75: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• My Web search informed me that if I change the RAM value to 512, things should be OK

• For the device I’ve chosen to illustrate with, I took memory size values of 256

• These are not large, which may account for the slowness I encountered, but at least they worked

Page 76: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Continuing with Virtual Device Creation

• Once you’ve got the parameters set, click on OK

• The system can drag on for a noticeable amount of time creating the virtual device

• Successful completion is indicated by the appearance of the device in the list as shown in the screenshot on the following overhead

Page 77: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 78: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• There is no final OK step after virtual device creation

• You’re done—and you have to close this window

• If you just minimize it, it sits there but is still the active window

• To go on from here, close this window

Page 79: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

1.7 Running an App on the Emulator in Eclipse

• There are several different ways of running an app in the emulator

• Later on you will find out that you can create run configurations and debug configurations which are linked to a project

• This is a fine way of doing business, but not necessarily the best way initially

Page 80: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Starting the emulator can take a lot of time• Trying to run the app and having that process

start the emulator isn’t necessarily the best plan

• The alternative is to start the emulator and then run the app in it

• This second approach is a better way to do it initially

Page 81: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Starting the Emulator

• The Android Virtual Device screen is shown again on the following overhead with the created virtual device in it

• The screenshot shows the device as being selected and you’ll note a Start… button on the right hand side

Page 82: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 83: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• If you click the Start button the following screen should appear

• This is the magic moment• Click Launch

Page 84: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 85: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• After clicking launch, you should see the screen with the progress bar shown on the following overhead

• So far so good

Page 86: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 87: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Even before the previous screen goes away, or at the very least, as soon as it finishes, you should see the emulator on the screen

• It’s conceivable that you’ll have to close some things to find it

• It may be hidden• In any case, the initial stage of launch shouldn’t

take a long time, and this is what you should see

Page 88: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 89: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Even If Things are Going OK, This is the Painful Part

• What you need now is tremendous patience and faith

• The Android message will flash white for an indeterminate period of time

• The emulator is still launching• As long as that process is going on, there’s

nothing else that you should do• Find something to kill a little time with, because

a watched pot never boils

Page 90: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Edging Towards Success

• Eventually, with good luck, the emulator will look as shown on the following overhead

• In the screenshot that is shown, the emulator screen is grayed out

Page 91: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 92: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• If your emulator is grayed out, click and drag over the emulator screen with the mouse

• This should wake it up, as shown on the following overhead

Page 93: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 94: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Click on the circle as directed• If the apps are shown, as they are in the

following screenshot, you have been successful

• The emulator has been launched and is running

Page 95: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 96: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Running the Project in the Emulator

• If you want to run the project (without setting up run or debug) configurations, you need a source file for the project open in the Eclipse environment

• The screenshot on the following overhead shows the explorer on the left tracing the path to the MyFirstApp.java file, with that file open in the editor in the middle

Page 97: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 98: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Now go to the Run menu in the menu bar and take the Run option in it

• Or, there is a Run tool in the toolbar which you can click on

• Don’t mistakenly take the dropdown option on the tool

• Once again there may be a certain amount of waiting, but with luck, when you look at the emulator, this is what you’ll see

Page 99: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 100: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Click and drag over the emulator screen, and voila

Page 101: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 102: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

1.8 Running the Project on an Attached Device Instead of an Emulator

Page 103: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• For reference purposes, these overheads were prepared with the following:

• Windows 7• Eclipse, as already described• A Nexus 7 tablet

Page 104: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Getting the Device Ready

• On the running device, go to the App screen• Tap on Settings• Under System, find About tablet• Tap Build number 7 times• When you return from doing this you should

find Developer options under System

Page 105: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Take Developer options• Under Debugging, enable USB debugging• Connect the device to your system using a USB

cable

Page 106: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Downloading and Installing the Driver

• Downloading:• Go to the Nexus 7 Web site• Get the download installer• Follow the download directions• Note which folder the driver is saved in

Page 107: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Installing:• Right click on your computer• Take the Manage option• Select the Device Manager on the left• Find and expand the Other devices• Find the Nexus 7 device in the list and right click on it• Take the Update Driver Software… option• Follow the directions and browse to the location

where the driver was saved to

Page 108: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

Running the App on the Device

• Open your app in Eclipse• Take the Run tool or the Run option in the

menu• If all of the preliminary steps were taken, this

should cause the Android Device Chooser to appear on the screen, with the Nexus 7 device in the list

• This is shown on the following overhead

Page 109: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time
Page 110: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

• Select your device and click OK• The magic should happen

Page 111: Android 1: Background Kirk Scott. 1.1 Buzzwords 1.2 Development Software 1.3 Getting Started 1.4 Preliminaries to Trying to Make It Work the First Time

The End