Thứ Sáu, 25 tháng 4, 2014

Eclipse [Getting Started with Android Programming]

The next step is to obtai the integrated development environmen(IDE) for developing your Androi applicationsIn the case of Android the recommended IDE is Eclipse, a multi-language softwar development environment featurin 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 Androi development, you should download the Eclipse IDE for JavEE Developers (www.eclipse.org/downloads/). Six editions are available: Window (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. Althe examples in this book were tested using the 32-bit version of Eclipse for Windows.

Once the Eclipse IDE is downloaded, unzip its conten (the eclipse folder) into a folder, say C:\Android 4.0\. Figure 1-14 shows the conten of the eclipse folder.


FIGURE 1-14


To launch Eclipse, double click  on the eclipse.exe file. You are first asked to specify youworkspace. 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 Androi 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 Androiapplications. 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 appea in the middle of the windo(see Figure 1-16). Expand  it to reveal itscontent Androi DDMS, Androi Development ToolsAndroi Hierarchy Viewer, and Androi 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. Oncthe installation is completed you will be asked to restar Eclipse. Go ahead and restart Eclipse now.

When Eclipse is restarted, you are asked to configure your Androi SDK (see Figure 1-17). As the
Androi SDK has already been downloadeearlier in the previous section, check the “Use existing SDKs optio and specify the director where you have installed the Androi SDK. Click Next.

Aftethis step, you are asked to send your usage statistics to Google. Once yohavselecteyouchoice, click Finish.


FIGURE 1-17

Creating Android Virtual Devices (AVDs)

The next step is to create an Androi Virtual Device (AVD) to be used for testing your Androiapplications. An AVD is an emulator instance that enables you to model an actual device. Each AVconsists of a hardware profile;a mappin to a system image; as well as emulate storage such as secure digital (SD) card.

You can create as many AVDs as you want in order to test your applications with several differenconfigurations. 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 Windo  AVD Manager (see Figure 1-18).


FIGURE 1-18

In the Androi Virtual Device Manager dialog (see Figure 1-19), click the New...  button to create a new AVD.


FIGURE 1-19

In the Create new Androi 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 Androi emulator) that emulates an Android device runnin 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 thayour application can be tested on different versions of the Androi 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 appea (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 sethe emulator to a smaller size. Click the Launch button to start the emulator.


FIGURE 1-21


The Androi emulator will start and after a while it will be ready for use (see Figure 1-22). Gahead and try out the emulator. It will behave just like a real Androi device. After that in the nexsection you will learn how to writeyour first Androi application!



FIGURE 1-22

Không có nhận xét nào:

Đăng nhận xét