您的位置:首页 > 移动开发 > Android开发

android平台的搭建(转载)

2012-06-11 21:14 260 查看


Setup Android Development Environment- Complete Tutorial

Here starts our Android Development tutorial. In this article, you will find how to setup a complete Android Development environment. This includes download, installation and configuration of various software components required to form a complete IDE. As
I said in the Introduction,
I’ve tried to keep things as simple as I could. And all you’re supposed to do is to follow some simple steps only. That’s it, not any big deal (Android Development itself is not a big deal and here it is made even more simpler).

This tutorial is based on Windows platform as I’m currently developing on Windows. The setup procedure for Linux and Mac platforms don’t make much difference and all tools required are available for that platforms also. Two things you are required to have is
a computer and an internet connection- preferably a high speed one. This is because all those components you are going to download will together consist of several hundreds of megabytes. If you have a low speed dial-up data connection, it will take much time
to complete.


These are the components you require to setup your Android IDE:

Java Development Kit

Android SDK

Eclipse

Now its time to download these one by one:

JDK(Java Development Kit)

It is the most important one as it forms the base for all other tools. It consists of Java Run time Environment and developer tools. For everything we are going to do here, JDK is required. To download Java SE JDK go to the Java SE download page of Oracle
here:

http://www.oracle.com/technetwork/java/javase/downloads/index.html



Accept the Licence agreement and select the platform

Android SDK

Android SDK is the collection of various tools and libraries which is designed to be linked with the development software we are using and make the development environment Android-specific. In our case it is to be linked with the Eclipse (Eclipse is not the
only development environment for Android. We use it here ‘cause it is the most popular and simple to work with). Download the latest Android SDK from Android Developers website

You can download either the executable installation file or the compressed archive. Both are same.

http://developer.android.com/sdk/index.html





Eclipse

Eclipse is the highly popular IDE for Java and here we are going to make it an Android specific IDE by installing the ADT plugin and linking with the Android SDK. That is, you are going to do all your coding, testing and debugging works in the Eclipse.

Before downloading the Eclipse, make sure that it is compatible with the Android SDK you’ve just downloaded before.

Currently Eclipse Classic is the recommended version

Download it from here:

http://www.eclipse.org/downloads/



Installation:

We’ve completed downloading all the tools essential to start with, now we’ll see how to install these components.

JDK

Installation of the Java SE is a relatively painless task. I think it doesn’t need much explanation. It is an executable installation package and install it like any other software packages. Leave the default packages and installation location unchanged and
proceed. After it completes installing JDK, will ask the location for JRE to be installed. No need to change the default location. Click next. After the successful completion of the installation, it will show you a window like this. Click continue

Android SDK

If you’ve downloaded the zip file of Android SDK, then you need to unzip the archive into the C: drive of your computer such that the software goes into C:/ android-sdk-windows folder (in case of Windows platform). If you downloaded the installation package
of Android SDK then install it by setting the installation location to your C:/ root folder.

Eclipse

Eclipse is also zip archive and doesn’t need installation. Just extract the zip file and place it in your C: drive such that the Eclipse software is in C:/Eclipse folder. Then go to that Eclipse folder and find a file namedEclipse.exe.
Right click on the file and select Create Shortcut. Copy the shortcut and place it in you desktop.

ADT Plugin for Eclipse

ADT is a custom plugin for Eclipse to give a powerful integrated IDE for Android Development. It allows user to develop, run and debug Android Applications.

Open Eclipse by double clicking the Eclipse shortcut on the desktop. It will ask for the default workspace location. Set it as C:/ Eclipse workspace and continue.

Eclipse window appears. Go to Help->Install New Software



In the new window click Add



Add Repository window opens

In the name field enter ‘ADT’

In the location field add the URL https://dl-ssl.google.com/android/eclipse/ href="http://www.android-app-market.com/wp-content/uploads/2012/02/add-repository.jpg" target=_blank>



Click OK

If any trouble occurs in downloading, use http in place of https in the URL

In the next window, you will see the list of files to be downloaded. Click Next



Next window shows the review of files to be installed. Click Next. Accept the Apache license and continue.

After the installation completes, it will ask you to whether restart the eclipse or not. Click restart Now



When Eclipse restarts, configure SDK window appears. Select Use existing SDK option and browse the folder C:/ android-sdk-windows and
click Finish.





Adding Platform Packages to the Android SDK

We’ve downloaded the Android SDK, but we can’t start development with the Android SDK as it is. This is because it doesn’t contain any packages. We need to add packages to the Android SDK. Packages are specific to a particular version of Android, for example,
if we are planning to develop for 2.3, then we want to install the platform packages for Android 2.3 that is API-10. Suppose we want to support the earlier versions of Android and want to test whether our app works without errors in the earlier versions or
not. Then we need each of those platforms of the Android versions we are planning to add support to.

Open Android SDK manager. You can open it from its folder or by just clicking the Android SDK manager button on the SDK toolbar.



When opens, it will automatically show the packages available for download.

Expand tools on the left. Select SDK tools and SDK platform tools.



To select the required packages expand them. Select SDK packages and samples
for SDK and GoogleAPI. You need not install the third party SDKs unless you are programming for a particular device.
(Google API is also not mandatory, it is required only if we use any Google APIs in our application. For simple applications, it isn’t required) As a beginner, you need to download SDK platform and samples for Android 2.3. Select Google USB driver package
under extras, if you want to test your app on a physical device.

After selecting, click Install Packages.

In the next window, the components we’ve selected appears as a list and we can make a review. To reject a package, select it and click Reject.



After making the final list of components, click install.

Setup Android Virtual Device

The final step is to configure an Android Virtual Device. Android Virtual Device is the Android emulator on which we are run our program. We can create an AVD to match with the configurations of any Android device available in the market. And there’s no limit
in the number of AVDs, we can create as many AVDs as we want in different configurations.

To create an AVD, go to Android Virtual Device Manager button in the Eclipse toolbar. Click New on the Right side.



Give any name in the name field. (The name should be such that you can distinguish it later, when multiple AVDs are created). Select the target API from the drop down list. In this case, I’ve selected 2.3 as target. Enter desired size for SD card. Under skin
section, leave the default resolution, WVGA800 unchanged.

Click
create AVD.

The Android Virtual Devise you’ve just created appears on the list of AVDs. Select it and click Start

Now
your AVD boots. It will take several minutes to load for the first time. After the loading is completed, it shows you an Android Home screen. This is your virtual Android devise where you are going to test- run your programs.



Congrats! You’ve completed an important task in your Android development life. You just setup you complete Android Development Environment. You will learn more about the development environment in my upcoming posts.

Stay tuned to Android-App-Market.com for all future updates

What do you think about this article? Please add your valuable comments and feedback below

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: