Chapter     3

Setting Up Your Android Development Environment

It’s time to get your hands dirty. In this chapter, starting from scratch, you’ll equip a computer system to develop Android applications. You’ll first install Oracle’s (formerly Sun’s) Java 6 SE JDK and the Java 6 Runtime Environment, then the Eclipse for Java EE IDE, and finally the Android SDK, the tool set that provides Eclipse with the tools you’ll need to create Android apps. Sound convoluted? It is. After all, this is high-end software development, remember. What these Software Development Kits (SDK) are, and how exactly they relate to each other will become evident as you proceed through this chapter.

Once the installation process is complete, you’ll finish up by fine-tuning your Android Development environment within Eclipse to include smartphone and tablet emulators, which let you test your app with a representation of an Android phone or tablet on your workstation. You’ll also have USB driver support, which makes it possible for you to test your applications on a real-live Android smartphone or tablet. With these tools in place, you’ll be ready to rock and roll, and you can begin to explore exactly how Android does things.

Installing Java, Eclipse, and Android

If you have not downloaded the required software as described in Chapter 1, you will need to do that before proceeding, so those packages are ready to install. Here, we will walk through installing Java 6 SE and the Java 6 JRE, Eclipse Juno 4.2 for Java EE, which is the IDE that is currently best suited for the Android SDK, the Android SDK itself, and the Android Development Tools (ADT). For the examples in this chapter (and book), we will install the software using 32-bit versions on a Windows 7 system, however you can also use Windows XP, Vista, or Windows 8, as long as you have them upgraded to their latest service pack versions. Android SDK is 32-bit, and looks for 32-bit Java 6 and 32-bit Eclipse on installation, but if you have a 64-bit workstation (as I currently do) don’t worry a bit, as 64-bit workstations will run 32-bit software environments perfectly well. Because Android OS is currently 32-bit, we will develop for it using a 32-bit development environment, even if that development environment is running on top of a 64-bit operating system.

Note that Android 4.2 now supports a full 64-bit Android development environment, so we added a section at the end of this chapter covering that support via a new ADT Bundle installation that is now available on the Android Developer web site. Luckily, we were able to add this information before the book went to print!

Note  Versions of the Java 6 JDK and Runtime Environment, the Eclipse Juno Java EE IDE, the Android SDK, and the Android Eclipse plug-in are also available for Macintosh and Linux computers. The steps to install them are nearly identical to those described in this chapter, and you will have no problems following along. For more information, click on the “other platforms” link on the left just underneath the big blue “Download the SDK for Windows” button on the Android Download screenshot in Chapter 1. If you are using Linux or Macintosh computers, then the Big Blue Button should instead say “Download the SDK for Linux” or “Download the SDK for Macintosh” instead!

Java 6 SE and JRE: Your Foundation for Application Development

In Chapter 1, you downloaded the latest Java 6 JDK from the Oracle website, so the file jdk-6u37-windows-i586.exe (or a similarly named file with later version numbering) should be on your desktop (or in your My Documents/Downloads/Folder) and ready to install.

The installation includes the Java 6 Runtime Environment (JRE), which is the environment that allows Java programs such as Eclipse to run, or execute, under the Java runtime engine. Indeed, this is the reason it is called a runtime—it is the environment, or software process, that is active while a Java application is running. Java Applications or “Apps” can be said to run “on top of,” or with the support of, this Java Runtime Environment. Note that each Java JDK has its own associated JRE, so be sure not to “mix and match” different Java revision SDKs (also known as JDKs) with other Java version JREs. JDK stands for: Java Software Development Kit, and thus saying JDK is the same as saying “Java SDK.”

Oracle has made the installation of the Java 6 SE environment relatively painless. The installation package is itself a software program (an executable, or .exe  file type) that will create the necessary folder structure on your hard disk drive and install all the Java 6 SDK files precisely where they need to go and where other software, such as the Eclipse for Java EE IDE, will be looking to find them.

Follow these steps to install the Java 6 SE SDK and its associated JRE:

  1. Double-click the JDK 6 install icon on your desktop (or in whatever folder you downloaded it to) to launch the JDK 6 setup application; at the time of the writing of this book, the current version was Java 6u37, or the 37th update of Java revision 6. If your operating system asks if it is OK to run the installation software, tell it to go right ahead.
  2. The next dialog tells you which files and features will be installed, and lets you turn off features that you do not wish to include. We are not going to touch anything in these set-up dialogs, so simply click Next to copy the more than 300MB of development files onto your hard drive, as shown in the installation screen sequence shown in Figure 3-1.

    9781430247883_Fig03-01.jpg

    Figure 3-1 .  Six dialogs for installing the 32-bit JDK 6 under Windows

  3. After installing the JDK 6 files, the installer will suggest a folder for the JRE, usually something like C:/Program Files/Java/jre6. Or if you have a 64-bit workstation, it will be C:/Program Files (x86)/Java/jre6. Simply hit the Next button to accept the default setting, as the JDK6 installer will find and use the correct folder names for you.
  4. Once the JDK 6 and JRE 6 have finished installing, the final screen will let you know of a successful installation, and provide a button for you to register the product online if you are currently connected to the Internet. It is most likely a good idea to register the JDK 6 (as well as the Eclipse Juno 4.2 for Java EE and the Android SDK), so that you can receive updates regarding their future development progress.

Eclipse Juno 4.2 for Java EE IDE: The Development Environment

Now that you have successfully installed Java 6 on your computer, you can install Eclipse Juno 4.2 for Java EE, which is the IDE you will use for your Android projects. You need to have Java 6 installed before you install and run Eclipse Juno for Java EE, because Eclipse Juno 4.2 for Java EE is written in Java, and thus requires the Java Runtime (JRE), which is part of the JDK install.

Note  An IDE is a software package somewhat like an advanced text editor, but with features specifically fine-tuned for writing computer programs rather than publishing text documents. If you want to get up to speed on all the amazing features of the Eclipse Juno IDE, run through the Help or Tutorials section once you have installed it, or get the book Android Apps with Eclipse from Apress.

In Chapter 1, you downloaded Eclipse Juno 4.2 for Java EE from the Eclipse website, so the eclipse-jee-juno-win32.zip file is on your desktop or in your MyDocuments/downloads/ folder and ready to install. Eclipse is a little harder to install than Java because it does not have an installation program (an .exe file, in the case of Windows), but instead has a folder structure of files inside a .zip archive. The trick is to extract this file structure properly onto your hard drive, so that Eclipse for Java EE can find the files that it needs, and so that they are in the folders where Eclipse and Android Development Tools (ADT) are going to look for them.

Follow these steps to install Eclipse for Java EE:

1.  Right-click the eclipse-jee-juno-win32.zip file in your Downloads folder, and select the option “Extract All. . .” to launch the WinZip extractor, as shown in Figure 3-2 (notice that the Extract All menu selection is highlighted in light blue, as well as circled in red).

Tip  If you don’t have WinZip, a free alternative called PKZIP is available for Windows, Mac, and Linux. Simply Google “PKZIP” or “ZIP File Utility” and download the free version for your operating system type now. Got it? Good. If you have Windows Vista or Windows 7, you can also open .zip files natively, using the Windows Explorer application, so you don’t need to download an extractor utility unless you want to.

9781430247883_Fig03-02.jpg

Figure 3-2 .  Right-click on the eclipse-jee-juno-win32.zip file in the Downloads folder to access the Extract All function

2.  Once you click on the Extract All menu selection, you will need to edit the default location to extract the Eclipse file structure into, so that it is in the root of your C: disk drive, as shown in the second dialog in the middle of Figure 3-3. This will put Eclipse into a folder structure (defined in the .zip file) under C:eclipse-jee-juno-win32, which is exactly where other software (in this case, the Android SDK) is going to look for (and find) it. Because the Eclipse Zip file is in your Downloads folder, the initial dialog for the Eclipse for Java EE IDE extraction will assume that that is where you want to install Eclipse (this is shown in the first dialog in Figure 3-3 in blue). So that it will be more prominent (and so you can find it at a later date) on your hard disk drive, we are going to move this up a few directory (folder) levels, by placing our editing cursor right before the word Eclipse, and backspacing over the “UsersYourNameDownloads” part of the filename specifier. Once you are done, the folder name should read “C:/eclipse-jee-juno-win32” as it does in the second dialog shown in Figure 3-3. Note that if you wanted to leave the default install path (and thus install) Eclipse under your Downloads folder, that other software could still find it there, and that it would still function from that location, it’s just not a best practice to install your software under (in) your downloads folder, although it is a good practice to download the installer files to this location (indeed that’s exactly what it is for: Downloads).

3.  Click the “Extract” button when you are ready and Eclipse 4.2 for Java EE will be extracted into the folder you have specified on your hard disk drive, with an extraction progress dialog showing the progress as seen in the next dialog screen shown in Figure 3-4. Note that if this folder does not exist on your hard disk drive (which it doesn’t by default) the extraction process will create it for you automatically, you do not have to create this folder before running this step!

9781430247883_Fig03-03.jpg

Figure 3-3 .  Renaming your Eclipse installation folder location to the top of your C: Drive

9781430247883_Fig03-04.jpg

Figure 3-4 .  Progress Dialog showing 3,426 items totaling 250 megabytes being installed on your HDD

4.  Next, go to the Windows Explorer application and click on the c:eclipse-jee-juno-win32 folder to view its file structure. Look for a folder called “eclipse” and in that folder a file called eclipse.exe, which is the actual Eclipse program “executable” (hence .exe) file that you will want to use to launch the Eclipse 4.2 for Java EE IDE each time you wish to use it to develop software.

5.  Right-click on the eclipse.exe file and select the Pin to Taskbar option, as shown in Figure 3-5.

9781430247883_Fig03-05.jpg

Figure 3-5 .  Creating a shortcut for Eclipse using the Windows 7 Pin to Taskbar Function via a right-click menu

6.  Selecting the Pin to Taskbar option will install the eclipse.exe shortcut icon onto your Quick Launch bar, and voila, you now have an icon that requires only a single-click to launch the Eclipse 4.2 Java EE IDE, as shown in Figure 3-6.

9781430247883_Fig03-06.jpg

Figure 3-6 .  Result of Pinning the Eclipse shortcut icon onto the Quick LaunchTaskbar in Windows 7

Congratulations, you now have one of the most powerful open source IDE software packages ever written, installed on top of Java 6 SE, ready to launch at a moment’s notice and use to develop Java or Android applications software. Now, all you need to do is install the Android SDK and Android Development Tools (ADT) and configure them inside of Eclipse, and you’ll be ready to develop Android applications ad infinitum. Cool beans.

Android SDK: Android Software Development Kit for Eclipse

The last major step in putting together an Android development environment is to install the latest Android SDK (currently at version 20.0.3 as of the writing of this book).

Note  To perform the SDK configuration and updates described in this chapter, you need to be connected to the Internet.

In Chapter 1, you downloaded the Android SDK from the Android website, so the file installer_r20.0.3-windows.exe  should be in your Downloads folder and ready to install. This process is quite similar to the installation of the Java 6 JDK. As you did with Java 6, install the Android SDK now, as shown in Figure 3-7.

9781430247883_Fig03-07.jpg

Figure 3-7 .  Installing the Android r20.0.3 SDK onto your hard disk drive

Notice that the SDK software installs into a Start Menu folder called Android SDK Tools. This is the folder where other software, such as Eclipse Juno 4.2 for Java EE, will look for the Android SDK, so it is best to use the default folder name that Google already has defined for Android inside the .exe installer file.

The Android SDK environment is now installed on your system. Because the Android Software Development Environment will run inside of the Eclipse 4.2 for Java EE IDE (the Android SDK needs to become an integrated part of Eclipse), you don’t need to create a shortcut for it—because you already have one for Eclipse that will also launch Android development.

The next step is to run the Android SDK Manager, which pulls over additional Android SDK Packages from a “Software Repository” at Google. This will add even more functionality to your Android software development environment, by pulling additional SDK assets over your Internet connection. Because running the Android SDK Manager is such a critical step, Google has made it an integrated part of the Android SDK installation process. As you can see in the next screenshot, after the Android SDK install is finished and you click the “Finish” button, the Android SDK Manager is auto-launched, so that you can continue to fine-tune your Android SDK installation. Be sure to leave the “Start SDK Manager” option checkbox checked before you click “Finish,” and the Android SDK Manager dialog will appear, showing that Android r20.0.3 is installed. Note also (at the bottom of the dialog, in the status bar) that it will look for additional software to install from the repository. You must be connected to the Internet for this process to occur, as the repositories are on Google’s servers, as shown in Figure 3-8 at the bottom of the last screen.

9781430247883_Fig03-08.jpg

Figure 3-8 .  Ending the SDK install and starting the Android SDK Manager in the same work process

Once the Android SDK Manager has finished communicating with the Google Android Repositories, a screen will appear as shown in Figure 3-9 that lists the Android Packages and software application programming interface (API) versions that are not currently installed on your system. Because this is a fresh install, this would be all of the Android versions from 1.5 through 4.1. The screen, which should show up next, is shown in Figure 3-9 with the recommended latest Android “Jelly Bean” 4.1 API tools shown checked and ready for installation. Note at the bottom that the SDK Manager is finished talking to the Google Android Repositories. Also note that there are two boxes that I recommend (as does Google) that you also check, so that you have the Android SDK Platform Tools and the Android Support Library, which gives the 4.1 Jelly Bean API backwards compatibility with the previous APIs to a large extent (but not completely, according to Google).

9781430247883_Fig03-09.jpg

Figure 3-9 .  Selecting the unchecked SDK Platform Tools and Android Support Library options

Once these nine options are all checked and selected for installation, click the button at the bottom on the right that says “Install 9 Packages” and the Android 4.1 API Level 16 tools will be installed into your Eclipse IDE. Note that because I show you the two that are unchecked (that you need to check), the button in the screenshot in Figure 3-9 says: Install 7 Packages. Once you check the additional two packages, this will update to: Install 9 Packages.

If you want to install the API packages for any previous API versions of Android, there are ten prior API revisions, three through fifteen, that can also be checked for installation. This is shown on the next screen in Figure 3-10, and if you are going to develop apps for hardware devices that run and support earlier versions of the Android OS, you may wish to install these as well.

Note  Beware that installing all of these APIs and documentation may represent gigabytes of data to download and install, and that this process may take some time (especially on slower Internet connections) and some hand-holding, as working with repositories is not always as “automatic” as we would like it to be!

9781430247883_Fig03-10.jpg

Figure 3-10 .  Selecting other Android APIs to install for the maximum cross-platform API development

Note that now that these other APIs are selected, that the Install Packages button says “Install 53 Packages,” so each API level has an average of about 5 packages associated with it. I recommend that for now that you just install Android 4.1, but I wanted to show you how to install all of the Android OS Platform API versions, in case you had a fast connection and are fearless in general regarding software installation. In any event, once you click the Install Packages button, regardless of which API levels you have chosen to install, you will get one more screen that confirms which packages you wish to install. This screen is shown in Figure 3-11.

9781430247883_Fig03-11.jpg

Figure 3-11 .  Selecting the “Accept All” option instructing that all packages be installed in Eclipse

At the bottom of this dialog, you will see a Radio Button option labeled “Select All,” and once you select that, all of the packages in the list (53 in this case) will be enabled for download from the Google Android Development Software Repository. Then, once you click on the “Install” button, as shown circled in red, you will begin the download process, and add all of this additional Android OS functionality to the “base” Android SDK that you have installed already.

What you need to do next is show Eclipse 4.2 for Java EE where the Android SDK is located, so that Eclipse can make the Android SDK functionality an integrated part of the Eclipse IDE. This is done by installing the Android Development Tool plug-in for Eclipse, which we will do in the next section.

Android Development Tool: Android Tools for Eclipse

It’s time to fire up Eclipse and add the Android Development Tool (ADT) plug-in to the IDE.

Follow these steps to perform the installation:

  1. Click the Eclipse Quick Launch bar icon to start Eclipse.
  2. Accept the default workspace location (it will be under your C:UsersYourNameworkspace folder).
  3. From the main Eclipse menu, select Help image Install New Software…, as shown in Figure 3-12.

    9781430247883_Fig03-12.jpg

    Figure 3-12 .  Selecting the Install New Software option on the Eclipse Help Menu

  4. In the Install dialog that appears, click the Add button at the upper right, as shown in Figure 3-13.

    9781430247883_Fig03-13.jpg

    Figure 3-13 .  Adding the Google plug-in for Eclipse 4.2 site to Eclipse Juno 4.2 for Java EE

  5. In the Add Repository dialog that appears, enter the name Google Plug-In for Eclipse 4.2 in the Name field. In the Location field, enter the following, as shown In Figure 3-13:

    Figure 3-13 shows the HTTP site address entered in the Add Repository dialog’s Location field. Click OK to add the site.

  6. Once you’ve added the new Google Eclipse 4.2 plug-in option, its name appears at the top of the Install dialog, and after a few moments, a hierarchy of Developer Tools options populates the center of the Install dialog. Select the first (highest) level, called Developer Tools (which will select them all), and the Google Plug-In for Eclipse (required) as shown in Figure 3-14. Then click Next to continue with the ADT installation. The plug-in proceeds to calculate installation requirements and dependencies for several seconds, so hang on!

    9781430247883_Fig03-14.jpg

    Figure 3-14 .  Installing Android Developer Tools and Google Plug-In for Eclipse 4.2 plug-ins in Eclipse

  7. The next screen shown in Figure 3-15 lists the Android Development Tools, Android Dalvik Debug Monitor Server (DDMS, which is a debugging tool), Google Plug-In for Eclipse 4.2, and some other useful Android development utilities. Click Next to accept these items.

    9781430247883_Fig03-15.jpg

    Figure 3-15 .  Reviewing the items to install for ADT and Google Plugin for Eclipse 4.2

  8. The next screen is agreeing to all of the ADT and Related Software Licensing Agreements; select the “I Accept the Terms of the License Agreements” radio button, and then click Finish as shown in Figure 3-16.

    9781430247883_Fig03-16.jpg

    Figure 3-16 .  Approving the software licenses for the Android Developer Tools

  9. The Android development environment will be installed and updated from the Google Android website. If a message appears asking you to approve an unsigned certificate, click OK to continue the installation, at which point you will see an installation progress screen like the one shown in Figure 3-17.

    9781430247883_Fig03-17.jpg

    Figure 3-17 .  Software installation progress bars outlining software being installed via the repository

  10. At this point the Android Development Tools and Google Eclipse 4.2 Plug-Ins will install as shown in Figure 3-17. If you want further installation files detail, use the Details button as shown in the screenshot (circled in red).
  11. A dialog appears, asking you to restart Eclipse to allow the changes you have just made to be installed into memory, and thereby take effect in the IDE (which runs from system memory, not from your hard disk drive). Select Yes, as shown in Figure 3-18.

    9781430247883_Fig03-18.jpg

    Figure 3-18 .  Opting to restart Eclipse to reload software installation changes into system memory

To make sure the Android Development Environment is now actually installed correctly, once Eclipse restarts go to the File image New image Project… Menu Sequence, and you should see an Android Application Project Type listed (inside or under the Android folder). Click the Arrow next to the Android folder, and it should look like the screen shown in Figure 3-19, outlining the various types of Android Projects that you can now develop in Eclipse. Click Cancel to exit the dialog, as we are not going to develop an Android Application now, we just wanted to confirm that there was an Android folder filled with Android Project types inside of the IDE, signifying that we have correctly added Android Application Development capabilities to Eclipse.

9781430247883_Fig03-19.jpg

Figure 3-19 .  Testing to see if ADT is installed in Eclipse by seeing if the New Android Application Project is there

Configuring the Android Environment Inside of Eclipse

Once Eclipse restarts and you confirm that you can now add new Android Application Projects, the final step is to configure the ADT plug-in, which should have already found your Android SDK installation. Let’s check and make sure, so you can see how this is done. Follow these steps:

  1. In Eclipse, select Window image Preferences. Click the Android node on the left to select the Android Preferences option. A dialog shown in Figure 3-20 will pop-up, asking you to share your usage information with Google, so that they can improve their product. You can choose to send usage info (or not to) via a checkbox in this dialog, as shown below. Click on the Proceed button to continue.

    9781430247883_Fig03-20.jpg

    Figure 3-20 .  Sending your Android Development Tools usage statistics to Google

  2. In the Preferences window, you will see that Eclipse has already found your Android SDK installation via the ADT plug-ins that you installed, as shown in Figure 3-21. It also shows the API versions that you added beyond Version 4.1, in my case, I added 2.3.3 and all of the 3.x and 4.x versions, as shown in the screenshot in Figure 3-21. Click on the Apply or the OK button, and the Android SDK will be updated as part of Eclipse (if it isn’t already), meaning that the Android development environment within Eclipse 4.2 will be configured.

    9781430247883_Fig03-21.jpg

    Figure 3-21 .  Viewing the Android Preferences dialog and installed SDK Targets and Android SDK location

    Note  You do not need to restart Eclipse again for the Android SDK to become a part of it because all the SDK needs is to be referenced in Eclipse, in case any of the SDK tools need to be called (used) by Eclipse.

  3. Select Help image Check for Updates just to make sure you have the very latest versions of everything, as shown in Figure 3-22.

9781430247883_Fig03-22.jpg

Figure 3-22 .  Instructing Eclipse to check for any IDE updates to make sure we have the latest versions

Your Android development environment will now check for updates to the Eclipse software to make sure that you have the most recent release available, as shown in Figure 3-23.

9781430247883_Fig03-23.jpg

Figure 3-23 .  Checking for any further updates for Eclipse that might be out there

If the Check for Updates routine finds any updates, which it did in my installation, it will show a dialog called “Available Updates,” and allow you to select which available updates you wish to install. In my case, there was a new version of the Google Plug-In for Eclipse 4.2, which is a critical component in the chain between Java image Eclipse image ADT, so I selected it for Installation, as shown in Figure 3-24.

9781430247883_Fig03-24.jpg

Figure 3-24 .  Selecting the latest available updates to install to make our environment as current as possible

Once you select the updates to install, and click on the Next button, you will get the Update Details dialog, as shown in Figure 3-25, which tells you the name, version, and repository location for the updates that you are about to install. Hit the Next button to proceed with the update process.

9781430247883_Fig03-25.jpg

Figure 3-25 .  Reviewing and confirming updates to install

The next dialog Is the Licensing Review and Acceptance dialog shown in Figure 3-26, where you need to select the radio button that states that you accept the terms of the license agreement for the update that you are about to install. Once you review the license and agree to it, click on the Finish button, and updating process will begin.

9781430247883_Fig03-26.jpg

Figure 3-26 .  Accepting the terms of the license agreement

Figure 3-27 shows the Updating Progress dialog that you will see once you agree to the licensing terms.

9781430247883_Fig03-27.jpg

Figure 3-27 .  Updating progress bar for software installation

After the software update download process is complete, you will get a dialog as shown in Figure 3-28 that warns that you are about to install software that contains unsigned content. Click OK to proceed with the installation.

9781430247883_Fig03-28.jpg

Figure 3-28 .  Unsigned software installation warning

Once the software is installed, you will get the dialog as shown in Figure 3-29 that tells you that for the newly updated version of Eclipse to be run (from system memory) that it must be restarted (to load the new updated code from your hard disk drive into system memory for use).

9781430247883_Fig03-29.jpg

Figure 3-29 .  Restarting Eclipse to install the latest software updates into your system memory

Now that we have updated the Eclipse Juno 4.2 for Java EE to its latest version, it’s time to set-up Android Virtual Devices (AVDs), so that we can test the applications that we write in this book.

Setting Up AVDs and Smartphone Connections

The Android development environment ships with AVDs, which lets you run your applications on a graphical representation of an Android handset, otherwise known as an emulator. You’ll want to install one now, before you begin to write code, so that you can test your apps.

AVDs: Smartphone and Tablet Emulators

To install an AVD, you use the Eclipse Juno 4.2 AVD Manager menu item. Here are the steps:

  1. To open the Android AVD Manager window, click the icon located at the top left of the Eclipse toolbar (see Figure 3-30) or select Window image AVD Manager.

    9781430247883_Fig03-30.jpg

    Figure 3-30 .  Starting the AVD Manager

  2. In the Android AVD Manager window, select the New button (see Figure 3-31).

    9781430247883_Fig03-31.jpg

    Figure 3-31 .  Creating a new AVD to test Android 4.1 compatibility in an Android 4.1 emulator

  3. Fill in the Create new Android Virtual Device (AVD) dialog as follows:
    • Enter a name for the emulator in the Name text box. I used the name Android_4.1_Emulator.
    • From the Target drop-down menu, select an API. I chose the Android 4.1 - API Level 16 from the menu of all the APIs installed.
    • In the SD Card section, set a memory card size for the SD card. I selected a size of 512MB (for the widest phone and tablet support).
    • In the Skin section, choose a screen resolution for the device skin. I selected the default WVGA screen setting because my Android phone has an 800 × 480 resolution display. Most Androids smartphones and tablets out there use WVGA or higher resolution, so by choosing this option, you’ll obtain the widest phone handset and tablet compatibility.
    • Check the Snapshot Enabled Checkbox to allow the emulator to persist (remain) in memory between executions for faster emulator performance during development.

    Figure 3-32 shows the dialog I completed to create an Android 4.1 smartphone emulator. Click the Create AVD button after you’ve filled in the dialog.

9781430247883_Fig03-32.jpg

Figure 3-32 .  Creating the 4.1 emulator for testing our apps later on in the book

As you can see in Figure 3-33, the new virtual device is now listed in the Virtual Devices’ section of the Android AVD Manager window. If you also are going to test applications on the other Android Platform versions that you have installed, go through this same process, and add these emulators as well at this time. Some more popular Android versions include 2.3.7, 3.2.6, and 4.0.4.

9781430247883_Fig03-33.jpg

Figure 3-33 .  The Android 4.1 emulator once it is added to the list of installed AVDs

USB Smartphone Drivers: External Devices

Because the latest USB driver for Android was installed as part of the SDK installation process in a previous section, you’ve already taken care of installing the most up-to-date USB drivers to interface the Eclipse Juno 4.2 for Java EE IDE with your Android smartphone or tablet devices.

It is important to note that this driver is only for Windows. Using the external Android smartphone on Mac and Linux does not require this driver download.

The driver is not intended to make your Android phone or tablet visible to Windows. You can simply plug your Android device in via USB, and it will be visible on your Windows desktop. However, this driver is necessary to have the development interface to and from Eclipse 4.2.

Note that the USB driver that you installed earlier went into the ADT plug-in for Eclipse, not into the Windows driver registry. Possibly the term driver is misleading in this instance, as this driver provides the ability for Eclipse to talk with your Android smartphone, tablet, e-reader, or iTV set during development, so that Android packages (.apk files) can be transferred to the smartphone, tablet, e-reader, or iTV for testing and development purposes.

ADT Bundle and 64-bit IDE Support

Android 4.2 changed the installation process to set-up an Android IDE drastically, adding 64-bit support, and making the entire process much easier by making Android SDK, ADT, and Eclipse into one huge 400MB “Bundle” that can be downloaded and installed using fewer steps. I’ll go through it briefly here, because it’s much less work, and I’ll refer to figures used earlier in this chapter, instead of duplicating similar screens again here.

If you go to the Android Developer web site, you will now see a 400MB ADT Bundle download button, that is all you will need to get, along with the Java 6 JDK. If you want to use 64-bit Java and Android/Eclipse IDE on your 64-bit workstation, be sure to go to the same Java 6 site download area as you did to get the 32-bit Java 6 JDK, but instead download the 64-bit JDK for Windows jdk-6u37-windows-x64.exe making sure you uninstall any other versions of Java from your workstation first, before you install the latest 64-bit version. Also, when you download the ADT Bundle, make sure to select the 64-bit version radio button on the “accept our licensing terms before you download” screen.

After the Java 6 64-bit JDK is installed, use the same work process shown in Figures 3-2 through 3-6 to install the ADT Bundle ZIP file onto your hard disk drive. You can skip the work process shown in Figures 3-7 through 3-19, but you will still get the dialog shown in Figure 3-20 at some point asking you to allow Google to see how you use their product. The work process shown in Figures 3-21 through 3-23 is always a good idea to make sure that you’re current, and you will still need to set-up AVDs, as shown in Figure 3-30 through 3-33, so that you have Emulators for the Android device hardware that you want to test for and support. As you can see, the new ADT Bundle allows you to skip at least a dozen or more major steps in setting up your Android Development environment, so it’s a real boon for Absolute Beginners, that’s for sure!

Installing GIMP 2.8 for Image Editing for Android Apps

One last thing that we should install for use with Android Application development is the open source digital image editing and compositing software called GIMP, currently at version 2.8.2, and available for all of the same platforms (Windows, Macintosh, and Linux) that Android ADT is.

I’m not going to use any screenshots in this section, as downloading and installing GIMP 2.8.2 is relatively easy compared to what we just went through in this chapter to get an Android Development environment working on our system! Other leading open source software packages that you should Google the names of, and then download and install, for a complete Android, Business and New Media development workstation are: Audacity, Blender3D, RoseGarden, Apache OpenOffice, and EditShare Lightworks. Amazing free for commercial use software!

So, let’s get started with GIMP 2.8! Go to www.GIMP.org and click the orange download button at the top-right of the homepage, and go to the GIMP.org/downloads/ page and click the orange link at the top that says: Download GIMP 2.8.2—Installer for Windows XP SP3 or later. If you use Mac or Linux, then click on the link below that says: Show Other Downloads.

Once you click on the Download 2.8.2 for Windows link, you will get a dialog saying that you have chosen to open gimp-2.8.2-setup-1.exe—click on the Save button to save the 73MB file to your MyDocuments/Downloads/ Folder (unless you specify another location for the file at download time). Once the download is finished, you will have the GIMP 2.8.2 installer file. If you have more than one workstation, copy this file to a USB key, so that you can install it on all of your systems because it’s one hot piece of open source digital imaging software!

Find the file in your Downloads folder, using the Windows Explorer, and double-click on it to execute it, or double-click the recent file download entry for GIMP in your browser’s download manager (or right-click on the file, and select Open, Run or Install). Then select the language you want to install it in (I selected English), and you will get a colorful GIMP 2.8 Installer Screen.

Click the Install button on the right, and watch the fun begin! You will get a progress bar showing you hundreds of files, totaling hundreds of megabytes of powerful (free) digital imaging software, being installed on your system. When the install is done, select the Finish button and Voila! Done!

Once GIMP 2.8 and the other software packages that we suggested earlier are installed on your system, be sure and use the “Pin to Taskbar” work process that we showed in Figures 3-5 and 3-6 earlier in this chapter to add all of your cool new software to your LaunchBar in Windows, so that you can admire the sheer power of your Android development workstation at all times. While you are at it, drag a few of the key system utilities that you will use in app development from your Start image All Programs image Accessories folder to the Taskbar as well, such as the Notepad (a Plain Text Editor), Calculator, the CharacterMap Utility, and your OS MediaPlayer.

Whew! We’re finally finished! Now we can get on to the business of Android development!

Summary

To set up your Android development environment, you began by installing the Oracle Java SE 6 JDK, which is required to run the Java programming language, and then the Eclipse 4.2 for Java EE IDE (Java EE is proof that Java can indeed be used to develop very large-scale, enterprise-quality applications).

Your next major step was to install the Android SDK, which contains all of the tools and utilities that you will need to develop Android applications. Once the SDK was installed on your hard drive, you went into Eclipse and pointed Eclipse to the Android SDK installation directory, so that Eclipse and Android’s SDK can work seamlessly hand in hand.

With the JDK and Android SDK installed, the next logical step was to install ADT into the Eclipse IDE, which the Android development environment uses as a “host,” or platform, to support its ADT plug-in.

After installation, you used the Eclipse Check for Updates features to check on the Internet for the very latest versions of the Eclipse and Android development tools. You installed the updates that were necessary (which unfortunately takes a while, even on a fast connection). Next, you added an AVD on which to test your future Android applications, which you soon will be coding like a Pro.

Finally, just to make sure that you put together a comprehensive Android Development Workstation, you stepped through the installation of GIMP 2.8 (which is used in this book for digital imaging work processes), and also you wisely downloaded and installed the five recommended leading open source packages in each genre that we do not specifically reference in this book but that you will eventually use in your Android development work process.

For digital video editing, that would be EditShare Lightworks; for 3D—Blender 3D; for digital audio editing—Audacity; for business tasks—Apache OpenOffice; and for music composition—RoseGarden. This is admittedly a bit beyond the “call of duty” of this book, but we figured, hey, if you are going to spend a day configuring your Android Development Workstation, why not go all the way, and do that for every type of new media development that Android supports, and get it over with? Besides, having all of these professional packages on your workstation makes it just that much more valuable than it was at the start of this chapter. Congratulations, you have just recovered what you paid for this book a hundred times over! In the next chapter, we’ll examine the Android platform and all of its components, to prepare for writing Android applications. And speaking of prepared, after this chapter, your Android development workstation is ready to Rock!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.238.227.73