News:
- In an internet driven environment, it is imperative for a company to keep its product or business to the forefront of potential customers' minds. The ...
- A successful enterprise is all about constantly reinventing ways to work more efficiently. In today’s techno age, this translates to testing new too...
- The IT industry plays a pivotal role in providing application development solutions and custom software development to a wide range of industries, i...
- Royal Victorian Eye and Ear Hospital, 2010 Atcomm has been contracted to implement a complex IOP glaucoma management tool which will be distribut...
- We are pleased to announce another implementation of a CMS system for a large Melbourne based fitness center - Star Plate Studio. Atcomm has depl...
Friday, 16 July 2010 16:46
Getting Your Feet Wet
-
font size
decrease font size
increase font size
In the last chapter, we provided an overview of Android’s history and we hinted at concepts we’ll cover in the rest of the book. So by this point, you’re probably eager to get your hands on some code. We’ll start by showing you what you need to start building applications with the Android Software Development Kit (SDK) and help you set up your development environment. Next, we’ll baby-step you through a “Hello World!” application and dissect a slightly larger application after that. Then we’ll explain the Android application lifecycle and end with a brief discussion about debugging your applications.
To build applications for Android, you’ll need the Java SE Development Kit (JDK), the Android SDK, and a evelopment environment. Strictly speaking, you can develop your applications using a primitive text editor, but for the purposes of this book, we’ll use the commonly available Eclipse IDE. The examples in this book target Android SDKs 1.1 and 1.5. (Chapters 12 and 13 focus on material specific to Android 1.5.) The Android SDK requires JDK 5 or higher,and we use JDK 6 with the examples. Moreover, the Android SDK requires Eclipse 3.3 or higher; we use Eclipse 3.4 (Ganymede).
Finally, to make your life easier, you’ll want to use Android Development Tools (ADT). ADT is an Eclipse plug-in that supports building Android applications with the Eclipse IDE. In fact, we built all the examples in this book using the Eclipse IDE (version 3.4) with the ADT tool.
Finally, to make your life easier, you’ll want to use Android Development Tools (ADT). ADT is an Eclipse plug-in that supports building Android applications with the Eclipse IDE. In fact, we built all the examples in this book using the Eclipse IDE (version 3.4) with the ADT tool.
Setting Up Your Environment
To build Android applications, you need to establish a development environment. In this section, we are going to walk you through downloading JDK 6, the Eclipse IDE, the Android SDK, and ADT. We’ll also help you configure Eclipse to build Android applications.
Downloading JDK 6 and Eclipse 3.4
The first thing you’ll need is the JDK. As we said earlier, the Android SDK 1.0 requires JDK 5 or higher, and we developed the examples using JDK 6. To get started, download JDK 6 from the Sun web site: http://java.sun.com/javase/downloads/index.jsp.
After you download the JDK, you’ll want to install it and set the JAVA_HOME environment variable to point to the JDK install folder. On a Windows machine, you can do this from a command line by typing this code:
set JAVA_HOME=[YOUR JDK_PATH_GOES_HERE]
Now, you can download the Eclipse IDE for Java Developers (not the edition for Java EE). Again, the examples in this book use Eclipse 3.4 (on a Windows environment), which you can download from http://www.eclipse.org/downloads/.
Downloading the Android SDK
To build applications for Android, you need the Android SDK. The SDK includes an emulator so you don’t need a mobile device with the Android OS to develop Android applications. In fact, we developed the examples in this book on a Windows XP machine.
You can download the Android SDK from http://code.google.com/android/download. html. The Android SDK ships as a .zip file for Windows, so you need to unzip it. Unzip the file to c:\AndroidSDK\, after which you should see the files shown in Figure 2-1.
Installing Android Development Tools (ADT)
Now you need to install ADT, an Eclipse plug-in that helps you build Android applications. Specifically, ADT integrates with Eclipse to provide facilities for you to create, test, and debug Android applications. You’ll need to use the Software Updates facility within Eclipse to perform the installation. If you are using Android 1.1, follow the instructions below. If you are using Android 1.5, refer to Chapter 12 for ADT installation. To get started, launch the Eclipse IDE and follow these instructions:
1. Select the Help menu item and choose the “Software Updates…” option.
2. In the “Software Updates and Add-ons” dialog, select the “Available Software” tab.
3. Click the “Add Site…” button and set the “Location” field to the ADT download site:https://dl-ssl.google.com/android/eclipse/. Click the “OK” button to add the site.You should now see the corresponding entry in the “Available Software” list as shownin Figure 2-2.
4. Expand the added entry by selecting the node in the list. You should see an entry named “Developer Tools” with two child nodes: “Android Development Tools” and “Android Editors.” Select the parent node “Developer Tools” and click the “Install” button to install ADT.
Eclipse will then download ADT and install it. You’ll need to restart Eclipse for the new plug-in to show up in the IDE. The final step to get ADT functional is to point it to the Android SDK. Select the Window menu and choose Preferences. In the “Preferences” dialog box, select the “Android” node and set the “SDK Location” field to the path of the Android SDK (see Figure 2-3). Then click the “OK” button. Note that you might see a dialog box asking if you want to send usage statistics to Google concerning the Android SDK.
You are almost ready for your first Android application—we have to briefly discuss the fundamental concepts of an Android application first.
To build applications for Android, you’ll need the Java SE Development Kit (JDK), the Android SDK, and a evelopment environment. Strictly speaking, you can develop your applications using a primitive text editor, but for the purposes of this book, we’ll use the commonly available Eclipse IDE. The examples in this book target Android SDKs 1.1 and 1.5. (Chapters 12 and 13 focus on material specific to Android 1.5.) The Android SDK requires JDK 5 or higher,and we use JDK 6 with the examples. Moreover, the Android SDK requires Eclipse 3.3 or higher; we use Eclipse 3.4 (Ganymede).
Finally, to make your life easier, you’ll want to use Android Development Tools (ADT). ADT is an Eclipse plug-in that supports building Android applications with the Eclipse IDE. In fact, we built all the examples in this book using the Eclipse IDE (version 3.4) with the ADT tool.
Finally, to make your life easier, you’ll want to use Android Development Tools (ADT). ADT is an Eclipse plug-in that supports building Android applications with the Eclipse IDE. In fact, we built all the examples in this book using the Eclipse IDE (version 3.4) with the ADT tool.
Setting Up Your Environment
To build Android applications, you need to establish a development environment. In this section, we are going to walk you through downloading JDK 6, the Eclipse IDE, the Android SDK, and ADT. We’ll also help you configure Eclipse to build Android applications.
Downloading JDK 6 and Eclipse 3.4
The first thing you’ll need is the JDK. As we said earlier, the Android SDK 1.0 requires JDK 5 or higher, and we developed the examples using JDK 6. To get started, download JDK 6 from the Sun web site: http://java.sun.com/javase/downloads/index.jsp.
After you download the JDK, you’ll want to install it and set the JAVA_HOME environment variable to point to the JDK install folder. On a Windows machine, you can do this from a command line by typing this code:
set JAVA_HOME=[YOUR JDK_PATH_GOES_HERE]
Now, you can download the Eclipse IDE for Java Developers (not the edition for Java EE). Again, the examples in this book use Eclipse 3.4 (on a Windows environment), which you can download from http://www.eclipse.org/downloads/.
Downloading the Android SDK
To build applications for Android, you need the Android SDK. The SDK includes an emulator so you don’t need a mobile device with the Android OS to develop Android applications. In fact, we developed the examples in this book on a Windows XP machine.
You can download the Android SDK from http://code.google.com/android/download. html. The Android SDK ships as a .zip file for Windows, so you need to unzip it. Unzip the file to c:\AndroidSDK\, after which you should see the files shown in Figure 2-1.
Installing Android Development Tools (ADT)
Now you need to install ADT, an Eclipse plug-in that helps you build Android applications. Specifically, ADT integrates with Eclipse to provide facilities for you to create, test, and debug Android applications. You’ll need to use the Software Updates facility within Eclipse to perform the installation. If you are using Android 1.1, follow the instructions below. If you are using Android 1.5, refer to Chapter 12 for ADT installation. To get started, launch the Eclipse IDE and follow these instructions:
1. Select the Help menu item and choose the “Software Updates…” option.
2. In the “Software Updates and Add-ons” dialog, select the “Available Software” tab.
3. Click the “Add Site…” button and set the “Location” field to the ADT download site:https://dl-ssl.google.com/android/eclipse/. Click the “OK” button to add the site.You should now see the corresponding entry in the “Available Software” list as shownin Figure 2-2.
4. Expand the added entry by selecting the node in the list. You should see an entry named “Developer Tools” with two child nodes: “Android Development Tools” and “Android Editors.” Select the parent node “Developer Tools” and click the “Install” button to install ADT.
Eclipse will then download ADT and install it. You’ll need to restart Eclipse for the new plug-in to show up in the IDE. The final step to get ADT functional is to point it to the Android SDK. Select the Window menu and choose Preferences. In the “Preferences” dialog box, select the “Android” node and set the “SDK Location” field to the path of the Android SDK (see Figure 2-3). Then click the “OK” button. Note that you might see a dialog box asking if you want to send usage statistics to Google concerning the Android SDK.
You are almost ready for your first Android application—we have to briefly discuss the fundamental concepts of an Android application first.
Read 27 times
Published in
Java