Figure 2-10: The Windows security warning.
Getting the Total Eclipse
After you have the SDK, you need an integrated development environment (IDE) to use it. It’s time to download Eclipse!
Installing Eclipse
To download Eclipse, navigate to the Eclipse downloads page at www.eclipse.org/downloads
. Select Eclipse IDE for Java Developers (Eclipse IDE for JAVA EE Developers works as well) and download the zip file.
To install Eclipse, extract the contents of the Eclipse .zip
file to the location of your choice, such as C:Program FilesEclipse
on Windows or in your Applications folder on a Mac.
On Windows, once you unzip Eclipse, pin a shortcut to your Start menu instead so that Eclipse is easy to find when you need it.
To start Eclipse, follow these steps:
1. To run Eclipse, double-click the Eclipse icon.
If you’re running a recent version of Windows, the first time you run Eclipse, a Security Warning dialog box may appear, as shown in Figure 2-10. It tells you that the publisher hasn’t been verified and asks whether you still want to run the software. Clear the Always Ask Before Opening This File check box, and click the Run button.
Figure 2-10: The Windows security warning.
2. Set your workspace.
When Eclipse starts, the first thing you see is the Workspace Launcher dialog box, as shown in Figure 2-11. You can modify your workspace there, if you want, but for this book, you can stick with the default:
c:users<username
>workspace
on Windows, or
Users<username>workspace
on a Mac
Leave the Use This As the Default and Do Not Ask Again check box deselected, and click the OK button.
If you plan to develop multiple applications, use a separate workspace for each project. If you store multiple projects in one workspace, maintaining organization becomes difficult, and you can easily change a similarly named file in a different project. Keeping projects in their own workspaces makes it easier to find the project when you have to go back to it to fix bugs.
When Eclipse finishes loading, you see the Eclipse welcome screen, shown in Figure 2-12.
Figure 2-11: Set your workspace.
Figure 2-12: The Eclipse welcome screen.
3. Click the curved-arrow icon on the right side of the screen to go to the workbench.
Eclipse is installed and easily accessible. You configure it in the next section.
Configuring Eclipse
The Android Development Tools (ADT) plug-in adds functionality to Eclipse to do a lot of the work for you. The ADT allows you to
Create new Android projects easily.
Start coding your application quickly because it creates all the necessary base files.
Debug your application using the Android SDK tools.
Export a signed application file, known as an Android Package (APK), right from Eclipse, eliminating the need for some command-line tools.
Programmers used to need various command-line utilities to build an APK. Although that task wasn’t difficult, it was tedious and sometimes frustrating. The ADT eliminates this frustrating process by guiding you through it “wizard style” from within Eclipse. Flip to Chapter 8 to export a signed APK.
Setting up Eclipse with the ADT
To set up Eclipse with the ADT, follow these steps:
1. Start Eclipse, if it’s not already running.
2. Choose Help → Install New Software.
The Install window opens. You use this window to install new plug-ins in Eclipse.
3. Click the Add button to add a new site.
A site is a web address where software is hosted on the Internet. Adding a site to Eclipse makes it easier for you to update the software when a new version is released.
The Add Repository window opens, as shown in Figure 2-13.
Figure 2-13: Enter the name and location of the site.
4. Type a name in the Name field.
This name can be anything you choose, but an easy one to remember is Android ADT.
5. Type https://dl-ssl.google.com/android/eclipse/ in the Location field.
6. Click OK.
Android ADT is selected in the Work With drop-down menu, and the available options are displayed in the Name and Version window of the Install Details dialog box, as shown in Figure 2-14.
Figure 2-14: Select Developer Tools.
7. Select the check box next to Developer Tools, and click the Next button.
The Install Details dialog box should list both the Android DDMS (see “Getting physical with a real Android device,” later in this chapter) and the ADT. See Figure 2-15.
8. Click the Next button to review the software licenses.
9. Click the Finish button.
10. When you’re prompted to do so, click the Restart Now button to restart Eclipse.
The ADT plug-in is installed.
Figure 2-15: DDMS and ADT listed in the Install Details dialog box.
Setting the location of the SDK
This section guides you through the configuration process. Completing it seems like a lot to do, but you’re almost done, and you have to do this work only once. Follow these steps:
1. Choose Window → Preferences.
The Preferences dialog box opens, as shown in Figure 2-16.
2. Select Android in the left pane.
3. Set the SDK Location to the folder to which you saved the Android SDK.
If you saved Android SDK to c:android
on your computer, the location is c:androidandroid-sdk-windows
.
4. Click OK.
Eclipse is configured, and you’re ready to start developing Android apps.
Figure 2-16: Specify the location of the SDK in the Preferences dialog box.