The first thing that we need to do before we can learn Android Application Development is to put together a working Android Application Development Environment on our development workstation. Hopefully you have an entry-level quad-core AMD or Intel computer with 4GB or more of DDR memory and Windows 7 or Windows 8; the computer that I will be using for this book is a $398 ACER 64-bit quad-core AMD, running at 3.1GHz with 4GB of DDR3 memory and 1TB hard disk drive and Windows 7 that I picked up at Walmart.
Fortunately for us Android App developers, very powerful 64-bit computers are readily available for a few hundred dollars! If you have a 32-bit computer, that will also work just as well for Android Application Development, because the Android 4.2 Development Environment comes in both 32-bit and 64-bit flavors. Additionally, all the software that we will be using for app development in this book is free for commercial use, also known as open source, so the cost of starting up your own Android Application Software Development business is quite low these days indeed.
If for some reason, you want to use a development environment that predates Android 4.2.2 (which I would strongly recommend against), there is an Appendix at the end of this book that covers the much more involved work process for installing the Android 4.1.2 development environment.
Our Plan of Attack
In this chapter, we will make sure that our system has the very latest versions of the Oracle Java 6 Software Development Kit (Java SDK, also known as the JDK, or Java Development Kit) programming environment, as well as the Android Software Development Environment, which consists of the Google Android Software Development Kit (SDK), Android Development Tools (ADT) Plug-ins for Eclipse, and the Eclipse 4.2 Integrated Development Environment (IDE).
All these installed together at once are cumulatively known as the Android ADT Bundle , which, as of Android 4.2, you can now download all at once, in under 400MB, at the Android Developer website at http://developer.android.com .
Before Android 4.2 Jelly Bean+ (Android API Level 17), developers had to download and install each of these components individually, which was quite tedious. If you want to do it this way, or see what it would be like to have to do it this way (and gain a greater understanding of what is going on between Eclipse and Android SDK and Android ADT) you can see the long-version of the install in Appendix A of this book.
Once our JDK is downloaded and installed, we will then download and install an Android Integrated Development Environment (IDE) called the Android ADT Bundle , the foundation of which is the Eclipse 4.2 Juno for Java EE IDE. Eclipse makes developing Android Apps easier by providing us with a slick Graphical User Interface (GUI) with which we can write, run, test, and debug our Android application code.
Eclipse runs on top of the Java Runtime Environment (JRE), because Eclipse is written in Java, and thus it uses the Java Platform to run its own codebase, which makes up the Eclipse IDE user interface and feature set, which you will see (as you progress throughout this book) is quite extensive indeed.
This is the primary reason that we downloaded and installed the Java 6 JDK first, so that the Java SDK and JRE are in place on our workstation. In this way, once we get into installing the ADT Bundle, which is based on Eclipse, Eclipse can easily find the Java Runtime Environment (so that Eclipse can launch and run). Once Eclipse is able to find Java it can use the Java SDK to build the Java programming code foundation for our Android Development Environment, because Android APIs (SDK) are based on the Java 6 APIs (SDK).
Once we have the ADT Bundle downloaded and installed and working smoothly on top of Java 6, we essentially have installed, all in one bundle, the Google Android Software Development Kit (SDK), the Eclipse 4.2.2 IDE, and all the ADT plug-ins needed to develop for Android 4.2.2 API Level 17.
For a birdseye view, if this process were formulated into an equation, it would look something like this:
JDK (Java 6 SDK) + ADT Bundle (Eclipse + Android SDK + ADT Eclipse Plug-Ins) = Custom Android IDE
As part of the Android Bundle installation and configuration for development usage work process (the second major part), we will install some Android Virtual Device (AVD) Emulators, which will live inside Eclipse 4.2, and which will allow us to test our applications on various Android Virtual Devices, such as a Virtual Nexus 7 Tablet, or a Virtual Nexus S Smartphone, or even a Virtual GoogleTV Set. So lets get started with this process now, so we can get it over with, and start developing apps in the next chapter!
Foundation of Android Programming: Java 6
The foundation of Android Application Development, both from a programming as well as an Integrated Development Environment (IDE) standpoint, is Java 6. Android Applications are written using the Java 6 programming language (and using XML as well, which well get into in more detail in ), and Android Apps are developed inside the Eclipse 4.2.2 IDE, which is also written in the Java 6 programming language, and which runs on top of the Java 6 Runtime Environment, also known as the JRE. To put it mildly, the exact order in which you set up the various software components that make up your Android Development Environment is very important, and is the reason for this first chapter.
So that we have both the Java programming language, which we gain access to via the JDK or Java Developer Kit, as well as the Java Runtime Environment (JRE), which is part of the JDK, go to the Oracle TechNetwork and download the latest JDK 6 installation software and install it on your machine. We do this first because Eclipse needs Java to run, that is, Eclipse can be said to run on top of the Java platform and language. Android also requires Java, as well as Eclipse, for its Android Developer Tools (ADT) plug-ins, so we install the Java Platform and Java Environment first, then the Android ADT Bundle.
Lets get started.
Installing the JDK
The first thing we must do is get to the Java SDK download page, and there are two ways to do this; one is generic, one is precise. The generic way, which will always work, even if Oracle changes the location of its Java SDK download page (which it probably wont), is to use Google Search with the keyword phrase Java SDK Download , which should bring up the Oracle TechNetwork Java download URL. The second way is to type the URL for the page directly into the browser. Here is the URL:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
What this points to is the Internet (HTTP) and the Oracle website in their TechNetwork area (folder) in the Java area (sub-folder) for the Java SE or Standard Edition area (sub-sub-folder) in the Downloads area (sub-sub-sub-folder). There are three primary versions of Java: SE or Standard Edition for individual users, EE or Enterprise Edition for large collections of users, and ME or Micro Edition for older mobile flip-phones. Most modern smartphones use Android and Java SE, rather than Java ME. One of the really cool things about Android is that it uses the full Standard Edition of Java (known as Java SE) just like a PC does. This is because Android runs on top of a full version of the Linux OS Kernel, so an Android consumer electronics device is essentially a full-blown Linux computer, for all practical purposes.