Book Image

Android Development Tools for Eclipse

By : Khirulnizam Abd Rahman, Sanjay Shah
Book Image

Android Development Tools for Eclipse

By: Khirulnizam Abd Rahman, Sanjay Shah

Overview of this book

<p>The increase in Android's popularity with every passing day cannot be understated. This has resulted in a large programmer base willing to contribute to its success. Eclipse has a powerful IDE and has been adopted widely by programmers across the globe. The focus of ADT is to use existing familiar territory and ease development of Android applications. In this sense, ADT provides a one stop solution for Android application development.</p><p>Android Development Tools for Eclipse is a step-by-step guide that provides you with hands-on, practical, and to the point discussion and steps for using Eclipse tools for developing, debugging, and signing Android applications for distribution. It also teaches you to incorporate advertisements to monetize your applications. Every concept and its usage has been demonstrated in this book by implementing them via real world applications.</p><p></p><p>Android Development Tools for Eclipse starts with the installation of ADT, and then discusses important tools before guiding you through Android application development from scratch, demonstrating different concepts and implementation before finally helping you distribute your applications in the Android market. You will start the development of your first application, explore project structure, and add different widgets including multimedia ones.</p><p></p><p>You will learn everything about developing, debugging, testing, distributing, and monetizing your Android application using Eclipse ADT.</p>
Table of Contents (10 chapters)
9
Index

Preparing for Android development

In this part of the chapter, we will see how to install the development environment for Android on the Eclipse Juno (4.2). Eclipse is the major IDE for Android development (see the following screenshot). We need to install eclipse extension ADT (Android Development Toolkit) for development of the Android Application:

Preparing for Android development

ADT on Eclipse in action

To download Android packages a Google API internet connection is a must, hence take this in notice before moving further. The steps on Windows using Eclipse Juno are as follows:

Software needed:

  • Latest JDK1.6.x from Oracle
  • Latest Android SDK
  • Eclipse 4.2 (Juno)

Installing the JDK

To check whether your PC has an existing JDK and it is installed correctly, go to command prompt, and type javac –version (as shown in the following screenshot). It is recommended to install JDK 1.6.x for Android Application Development as it may complain that the compiler compliance level is greater than 6, and could run into problems:

Installing the JDK

Checking the JDK version

You may download JDK 1.6 (Java Development Toolkit) from the download site and install it. Make sure that JAVA_HOME is set after the installation, and check the version executing the preceding command.http://www.oracle.com/technetwork/java/javase/downloads/index.html (see the following screenshot).

This step can be skipped if we have java 1.6.x installed:

Installing the JDK

Java PATH setting

Installing the Android SDK

Create a folder named android-dev (android-dev is just a suggestion; you may create another name instead). The folder android-dev will be used consistently throughout this chapter. This folder is to hold all the software that is needed for Android development. This folder is needed again in another procedure.

Download from http://developer.android.com/sdk/index.html, and install this software in the android-dev folder. Bear in mind this download only provides the basic tools of Android SDK, not the complete installation. Later, we need to download the Android system images, APIs, examples, documentations and other libraries:

Installing the Android SDK

Android SDK download page

After completion of the download, install the SDK in the folder mentioned earlier; in C:\android-dev\android-sdk as shown in following screenshot.

During the installation, the Android SDK will detect the Java Development Kit in the machine. If we have installed the latest JDK, it should have no problems:

Installing the Android SDK

Android SDK installation path

Installing the Eclipse (Juno)

Eclipse Juno (4.2) is available for download at http://www.eclipse.org/downloads/:

Installing the Eclipse (Juno)

Download page of Eclipse Classic

The Eclipse comes in a ZIP file, so just unzip it and find the eclipse.exe file to run it.

Immediately extract Eclipse in the folder as created earlier (in C:\android-dev). After the extraction, create a desktop shortcut to make life easier, as depicted in the following screenshot:

Installing the Eclipse (Juno)

Create Eclipse shortcut

Installing the ADT in Eclipse Juno

Run Eclipse by identifying the Eclipse installation folder and double-click eclipse.exe (or double-click the shortcut in the Desktop). Provide a folder to store all the projects' source codes. And once again, create this folder under the android-dev folder, as shown in the following screenshot:

Installing the ADT in Eclipse Juno

Select Eclipse Workspace

This new Eclipse installation does not provide the Android Developer Toolkits (ADT) plugins. To install this plugin navigate to Window | Preferences to open the Preferences panel. Click on Install/Update | Available Software Sites (on the left panel). Click on the Add button (on the right panel) to add a software download site (again an Internet connection is needed).

Another window will appear. Provide ADT in the Name (for example), and the Location https://dl-ssl.google.com/android/eclipse/(as provided in http://developer.android.com/sdk/eclipse-adt.html):

Installing the ADT in Eclipse Juno

In the Available Software dialog, select the checkbox next to Developer Tools and click on Next. In the next window, you'll see a list of the tools to be downloaded. Select all except NDK plugins and click on Next. We will be discussing the tools in the next chapters:

Installing the ADT in Eclipse Juno

Selecting the ADT and SDK tools

Read and accept the license agreements, then click on Finish. If you get a security warning saying that the authenticity or validity of the software can't be established, click on OK. When the installation completes, restart Eclipse.