The next step is to obtain the integrated development environment (IDE) for developing your Android applications. In the case of Android, the recommended IDE is Eclipse, a multi-language software development environment featuring anextensible plug-in system. It can be used to develop various types of applications, using languages such as Java, Ada, C, C++, COBOL, Python, and others.
For Android development, you should download the Eclipse IDE for Java EE Developers (www.eclipse.org/downloads/). Six editions are available: Windows (32- and 64-bit), Mac OS X (Cocoa 32- and 64), and Linux
(32- and 64-bit). Simply select the relevant one for your operating system. All the examples in this book were tested using the 32-bit version of Eclipse for Windows.
Once the Eclipse IDE is downloaded, unzip its content (the eclipse folder) into a folder, say C:\Android 4.0\. Figure 1-14 shows the content of the eclipse folder.
FIGURE 1-14
To launch Eclipse, double click on the eclipse.exe file. You are first asked to specify your workspace. In Eclipse, a workspace is a folder where you store all your projects. Take the default suggested (or you can specify yourownfolder as the workspace) and click OK.
Android Development Tools (ADT)
When Eclipse is launched, select Help ➪ Install New Software (see Figure 1-15) to install the Android Development Tools (ADT) plug-in for Eclipse.
FIGURE 1-15
The ADT is an extension to the Eclipse IDE that supports the creation and debugging of Android applications. Using the ADT, you will be able to do the following in Eclipse:
➤ Create new Android application projects.
➤ Access the tools for accessing your Android emulators and devices.
➤ Compile and debug Android applications.
➤ Export Android applications into Android Packages (APKs).
➤ Create digital certificates for code-signing your APK.
In the Install dialog that appears, specify https://dl-ssl.google.com/android/eclipse/ and press Enter. After a while, you will see the Developer Tools item appear in the middle of the window (see Figure 1-16). Expand it to reveal itscontent: Android DDMS, Android Development Tools, Android Hierarchy Viewer, and Android Traceview. Check all of them and click Next twice.
FIGURE 1-16
You will be asked to review and accept the licenses. Check the “I accept the terms of the license agreements” option and click Finish. Once the installation is completed, you will be asked to restart Eclipse. Go ahead and restart Eclipse now.
When Eclipse is restarted, you are asked to configure your Android SDK (see Figure 1-17). As the
Android SDK has already been downloaded earlier in the previous section, check the “Use existing SDKs” option and specify the directory where you have installed the Android SDK. Click Next.
After this step, you are asked to send your usage statistics to Google. Once you have selected your choice, click Finish.
FIGURE 1-17
Creating Android Virtual Devices (AVDs)
The next step is to create an Android Virtual Device (AVD) to be used for testing your Android applications. An AVD is an emulator instance that enables you to model an actual device. Each AVD consists of a hardware profile;a mapping to a system image; as well as emulated storage, such as a secure digital (SD) card.
You can create as many AVDs as you want in order to test your applications with several different configurations. This testing is important to confirm the behavior of your application when it is run on different devices withvarying capabilities.
To create an AVD, select Window ➪ AVD Manager (see Figure 1-18).
FIGURE 1-18
In the Android Virtual Device Manager dialog (see Figure 1-19), click the New... button to create a new AVD.
FIGURE 1-19
In the Create new Android Virtual Device (AVD) dialog, enter the items as shown in Figure 1-20.
Click the Create AVD button when you are done.
FIGURE 1-20
In this case, you have created an AVD (put simply, an Android emulator) that emulates an Android device running version 4.0 of the OS with a built-in 10-MB SD card. In addition to what you
have created, you also have the option to emulate the device with different screen densities and resolutions.
It is preferable to create a few AVDs with different API levels and hardware configurations so that your application can be tested on different versions of the Android OS.
Once your ADV has been created, it is time to test it. Select the AVD that you want to test and click the Start… button. The Launch Options dialog will appear (see Figure 1-21). If you have a small monitor, it is recommended thatyou check the “Scale display to real size” option so that you can set the emulator to a smaller size. Click the Launch button to start the emulator.
FIGURE 1-21
The Android emulator will start, and after a while it will be ready for use (see Figure 1-22). Go ahead and try out the emulator. It will behave just like a real Android device. After that, in the next section you will learn how to writeyour first Android application!
FIGURE 1-22
Không có nhận xét nào:
Đăng nhận xét