`
java-mans
  • 浏览: 11415295 次
文章分类
社区版块
存档分类
最新评论

Android第一课开发环境配置手册 ——Android4.1

 
阅读更多

前期准备工作,需要用到以下安装包:

1、JDK

2、Eclipse

3、Android SDK

4、ADT Plugin for Eclipse

JDK、Eclipse、AndroidSDK网盘Skydrive下载链接
版本

Java(TM) Platform SE 7 U5 jdk-7u5-windows-i586.exe

eclipse-SDK-4.2-win32.zip

Android android sdk-installer_r20.0.1-windows.exe

Android SDK包含了开发工具,不过基本都是字符界面的,Eclipse集成开发环境提供了很好的图形化开发界面,对Android SDK有很好的支持,现在一般都使用Eclipse作为Android的开发平台。

使用Eclipse开发Android的应用程序,需要下载Android的Eclipse插件(ADT)才可以把Android SDK集成到Eclipse的开发环境中。

备注:

Android推荐使用"EclipseClassic"作为开发平台。

本文中所使用的安装文件均为编写文档时最新版本,发布后续版本,请自行下载更新。

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


下面开始安装包,步骤如下:


步骤一:安装JDK

步骤二:分别解压缩Eclipse-SDK和Android-SDK到E:\Android路径下(路径自己配置)


Android Sdk安装时出现如下界面,如果没有,在sdk文件夹下运行SDK Manager.exe


罗列出没有安装的工具包。如下图,选择要安装包4.1,然后点击【Install n Package】。


在弹出的对话框中选择Accept all,接受全部安装


安装完成后如下图所示,左下角Done loading packages.


步骤三:在Eclipse中安装插件ADT

相见官网说明

http://developer.android.com/sdk/installing/installing-adt.html

Download the ADT Plugin


  1. Start Eclipse, then selectHelp>Install New Software....
  2. ClickAdd, in the top-right corner.
  3. In the Add Repository dialog that appears, enter "ADT Plugin" for theNameand the following URL for theLocation:
    https://dl-ssl.google.com/android/eclipse/
  4. ClickOK

    Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).

  5. In the Available Software dialog, select the checkbox next to Developer Tools and clickNext.
  6. In the next window, you'll see a list of the tools to be downloaded. ClickNext.
  7. Read and accept the license agreements, then clickFinish.

    Note: If you get a security warning saying that the authenticity or validity of the software can't be established, clickOK.

  8. When the installation completes, restart Eclipse.
Configure the ADT Plugin

After you've installed ADT and restarted Eclipse, you must specify the location of your Android SDK directory:

  1. SelectWindow>Preferences...to open the Preferences panel (on Mac OS X, selectEclipse>Preferences).
  2. SelectAndroidfrom the left panel.

    You may see a dialog asking whether you want to send usage statistics to Google. If so, make your choice and clickProceed.

  3. For theSDK Locationin the main panel, clickBrowse...and locate your downloaded Android SDK directory (such asandroid-sdk-windows).
  4. ClickApply, thenOK.

If you haven't encountered any errors, you're done setting up ADT and can continue to the next step of the SDK installation.

Updating the ADT Plugin


From time to time, a new revision of the ADT Plugin becomes available, with new features and bug fixes. Generally, when a new revision of ADT is available, you should update to it as soon as convenient.

In some cases, a new revision of ADT will have a dependency on a specific revision of the Android SDK Tools. If such dependencies exist, you will need to update the SDK Tools package of the SDK after installing the new revision of ADT. To update the SDK Tools package, use the Android SDK Manager, as described inExploring the SDK.

To learn about new features of each ADT revision and also any dependencies on the SDK Tools, see the listings in theRevisionssection. To determine the version currently installed, open the Eclipse Installed Software window usingHelp>Software Updatesand refer to the version listed for "Android Development Tools".

Follow the steps below to check whether an update is available and, if so, to install it.

  1. SelectHelp>Check for Updates.

    If there are no updates available, a dialog will say so and you're done.

  2. If there are updates available, select Android DDMS, Android Development Tools, and Android Hierarchy Viewer, then clickNext.
  3. In the Update Details dialog, clickNext.
  4. Read and accept the license agreement and then clickFinish. This will download and install the latest version of Android DDMS and Android Development Tools.
  5. Restart Eclipse.

If you encounter problems during the update, remove the existing ADT plugin from Eclipse, then perform a fresh installation, using the instructions forInstalling the ADT Plugin.

Troubleshooting


If you are having trouble downloading the ADT plugin after following the steps above, here are some suggestions:

  • If Eclipse can not find the remote update site containing the ADT plugin, try changing the remote site URL to use http, rather than https. That is, set the Location for the remote site to:
    http://dl-ssl.google.com/android/eclipse/
  • If you are behind a firewall (such as a corporate firewall), make sure that you have properly configured your proxy settings in Eclipse. In Eclipse, you can configure proxy information from the main Eclipse menu inWindow(on Mac OS X,Eclipse) >Preferences>General>Network Connections.

If you are still unable to use Eclipse to download the ADT plugin as a remote update site, you can download the ADT zip file to your local machine and manually install it:

  1. Download the current ADT Plugin zip file from the table below (do not unpack it). Name Package Size MD5 Checksum
    ADT 20.0.2 ADT-20.0.2.zip 12388464 bytes 8e727bcdc9789c900784a82e6330ec22
  2. Follow steps 1 and 2 in thedefault install instructions(above).
  3. In the Add Site dialog, clickArchive.
  4. Browse and select the downloaded zip file.
  5. Enter a name for the local update site (e.g., "Android Plugin") in the "Name" field.
  6. ClickOK.
  7. Follow the remaining procedures as listed fordefault installationabove, starting from step 4.

To update your plugin once you've installed using the zip file, you will have to follow these steps again instead of the default update instructions.

Other install errors

Note that there are features of ADT that require some optional Eclipse packages (for example, WST). If you encounter an error when installing ADT, your Eclipse installion might not include these packages. For information about how to quickly add the necessary packages to your Eclipse installation, see the troubleshooting topicADT Installation Error: "requires plug-in org.eclipse.wst.sse.ui".

For Linux users

If you encounter this error when installing the ADT Plugin for Eclipse:

An error occurred during provisioning.
Cannot connect to keystore.
JKS

...then your development machine lacks a suitable Java VM. Installing Sun Java 6 will resolve this issue and you can then reinstall the ADT Plugin.

_____________________________________________________________________________________________________________




1、启动Eclipse,选择菜单Help->Install New Software..




next


next


accept the terms.Finish


安装过程中,出现如下警告,点击【OK】即可。


安装完毕,提示重新启动Eclipse。


配置 ADT Plugin


安装 ADT 并重启 Eclipse后, 需指定 Android SDK目录位置:

  1. 选择Window>Preferences...t打开偏好面板(Preferences panel) (on Mac OS X, selectEclipse>Preferences).
  2. 在左侧面板选择Android.

    看到对话框询问是否 发送使用统计信息给Google. 是的话, make your choice and clickProceed.

  3. SDK Location主面板, 单击Browse...定位Android SDK 目录 (such asandroid-sdk-windows).

单击应用Apply, 然后点击OK.

I若没有遇到错误, 就完成了ADT设置,可以继续SDK安装的下一步。

步骤四:创建虚拟机

Android模拟器运行环境配置——新建AVD(android vitural device)和SD card

创建sdcard

进入android sdk\tools目录,运行mksdcard

在eclipse中安装了android环境后,可以直接创建AVD和sdcard的,windows->Android SDK and AVD Manager,创建一个AVD时,可以同时创建sdcard等。以下主要讲用命令行的方式创建这些东东。

一、 创建AVD

1.首先配置好环境变量,在path中加入模拟器路径,如D:/android-sdk_r06-windows/android-sdk-windows/tools;

2.然后打开命令行(快捷键Win+R),输入cmd;

3.列出所有的平台:android list target或者android list targets

4.创建AVD:android create avd–-name <your avd name> --target <targetID>其中your avd name是你自己AVD的名字,targetID是前面列出的平台id

或者android create avd –-n <your avd name> -t <targetID> (注意未简写时前面是--);

5.查看AVD是否创建成功:命令:android list avd

6.启动模拟器:命令:emulator -avdyour avd name

二、创建sdcard

1. mksdcard1024M D:/android/sdcard.img 第一个参数为创建的sdcard的大小,第二个参数为sdcard的路径及名字,建议以img为后缀。(注意路径中不能有空格出现)创建sdcard可能需要30秒左右,请耐心等待;

2. 导入刚创建好的SD卡到模拟器中:emulator -avd<your avd name> -sdcard D:/android/sdcard.img;导入好后模拟器会自动启动;

3. 在eclipse中可以查看sdcard中的信息,windows->show views-other-File explorer。

————————————————————————————————————————

打开Eclipse->AVD Manager

Create AVD
在建立sdcard.img的基础上,可以在创建AVD同时创建SD card

虚拟机创建完毕。

步骤五:启动虚拟机

AVD manager选择AVD,单击start

选择Launch启动虚拟机。

C盘容量已经满了,如下图,怎么办?

删除C盘多余的内容,使剩余容量大于512M。

————————————————————————————————————————————————————————

修改AVD路径

第一次使用 Android 的 SDK 时,可能有很多人纳闷如何修改 AVD 的位置,那么经过我的摸索和 Google 之,也经过实验,终于知道如何更改 AVD 的位置了,那么请看。

第一种方法,适合还没有建立 AVD 的情况

即:在计算机右击的属性|高级|环境变量,然后添加一个用户变量,名字为 "ANDROID_SDK_HOME”,然后把变量值改为你想将".android”文件夹(AVD信息)所放置的位置这样,你重新打开你的 SDK,看看存放的位置是不是变了?好了,那接下来第二种了。


第二种方法,适合在已经建立过AVD的情况

即: 修改配置文件中的路径,比如我的 AVD 名称是 Android,打开 C:\Documents and Settings\Administrator\.android\avd 目录中的文件 Android.ini 文件,找到
target=android-5path=C:\Documents and Settings\Administrator\.android\avd\MyAVD.avd (注意 Vista 和 W 7 这个路径在 C 盘你的用户名文件件中)修改其路径即可

注意:

1. AVD 路径中一定不能有中文,其他文不知道,但最好是英文,不然就出错。

2.若遇到ERROR: unknown virtual device name 这样的问题一般是由于AVD文件路径引用错误造成的。

————————————————————————————————————————————————————————————————————

以上,Android虚拟运行环境配置完毕。接着就可以进行Android开发了。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics