首页 Android_SDK与Eclipse最新版开发环境搭建

Android_SDK与Eclipse最新版开发环境搭建

举报
开通vip

Android_SDK与Eclipse最新版开发环境搭建 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 一、 背景和准备 1. Android 简介 Android是 Google于 2007年 11月 5日宣布的基于Linux平台的开源手机操 作系统的名称,该平台由操作系统、中间件、用户界面和应用软件组成,号称是 首个为移动终端打造的真正开放和完整的移动软件。可以把它简单理解成 Linux 上套了一个 JAVA...

Android_SDK与Eclipse最新版开发环境搭建
no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 一、 背景和准备 1. Android 简介 Android是 Google于 2007年 11月 5日宣布的基于Linux平台的开源手机操 作系统的名称,该平台由操作系统、中间件、用户界面和应用软件组成,号称是 首个为移动终端打造的真正开放和完整的移动软件。可以把它简单理解成 Linux 上套了一个 JAVA 的壳。 Android 的平台基本上是免费的,虽然有部份原生链接库会要求费用,但大 部份是免权利金。Android 的程序可以采用 JAVA 开发,因为它的虚拟机(Virtual Machine) Dalvik,只是它将 JAVA 的 bytecode 转成自己的 格式 pdf格式笔记格式下载页码格式下载公文格式下载简报格式下载 ,回避掉需要付 给 SUN 有关 JAVA 的授权费用。因此,Android 开发环境是需要 JDK 的。 2. Android 网络资源 Android的网站是:http://www.android.com/,目前还可以登陆,比较悲剧 的是:其Partners部分:http://source.android.com/和Developers部分: http://developer.android.com/,大陆地区已经无法访问。 Android的系统要求请参考: http://androidappdocs.appspot.com/sdk/requirements.html 当前最新版本的Android SDK下载器(真正的SDK还是需要另外下载的),小 生是无法直接到官网http://developer.android.com/sdk/index.html 下载的,于是 另外找了一个地址http://androidappdocs.appspot.com/sdk/index.html,下载 链接和说明如下: Android SDK for Windows android-sdk_r08-windows.zip http://dl.google.com/android/android-sdk_r08-windows.zip installer_r08-windows.exe (Recommended) http://dl.google.com/android/installer_r08-windows.exe Android SDK for Mac OS X (intel) android-sdk_r08-mac_86.zip http://dl.google.com/android/android-sdk_r08-mac_86.zip Android SDK for Linux (i386) android-sdk_r08-linux_86.tgz http://dl.google.com/android/android-sdk_r08-linux_86.tgz Here's an overview of the steps you must follow to set up the Android SDK: 1. Prepare your development computer and ensure it meets the system requirements. 2. Install the SDK starter package from the table above. (If you're on Windows, download the installer for help with the initial setup.) 3. Install the ADT Plugin for Eclipse (if you'll be developing in Eclipse). 4. Add Android platforms and other components to your SDK. 5. Explore the contents of the Android SDK (optional). 1 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 3. 软件包下载 a. JDK 1.6 下载网址: http://www.oracle.com/technetwork/java/javase/downloads/index.html 当前最新版本为 Java SE 6 Update 23 小生机器上安装的是:jdk1.6.0_21,也一样用,其实只要你是 JDK1.5 以上 就可以了。 b. Android SDK 下载器 下载地址上面已经给出了,可以根据你的系统选择不同的安装包。小生是 windows 2003 server,因此下载了 http://dl.google.com/android/android-sdk_r08-windows.zip,之后直接解压缩即可。 c. Eclipse IDE Eclipse 3.4 (Ganymede)以后版本均可。小生下载了最新版本的 Helios (3.6) 二、 JAVA 环境 Windows 上配置 JAVA 环境变量如下: JAVA_HOME Path: 2 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 三、 Android SDK 安装 Android SDK 可以通过 SDK 下载器自动下载和配置,适合网络好,下载速 度快的情况下;也可以借助工具下载 SDK 文件,手工配置,适合网络不是很好, 下载速度慢的情况下。 SDK 下载器自动下载 步骤 新产品开发流程的步骤课题研究的五个步骤成本核算步骤微型课题研究步骤数控铣床操作步骤 如下: 1. 解压缩 android-sdk_r08-windows 下载器,并双击运行 SDK Manager.exe: 如果你的电脑不支持 https 连接会看到如下界面: 3 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 请选择 setting 的将 Force https://... Sources to be fetched by using http://... 的选 项打勾 2. 勾选你想要安装的 Packages,并点击 Install Selected 进行安装: 4 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 3. 确认对话框如下,选择 Accept All 进行下载安装 4. 则 Android SDK 下载器进入下载安装的过程 5 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 5. 根据你网速的情况,下载安装的时间或长或短,请耐心等待。 手动下载步骤如下: 1. 通过分析Android下载器的 http://dl-ssl.google.com/android/repository/repository.xml 内容,可以得到如 下下载列 关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf (以Windows环境为例): http://dl-ssl.google.com/android/repository/android-1.5_r04-windows.zip http://dl-ssl.google.com/android/repository/android-1.6_r03-windows.zip http://dl-ssl.google.com/android/repository/android-2.0_r01-windows.zip http://dl-ssl.google.com/android/repository/android-2.0.1_r01-windows.zip http://dl-ssl.google.com/android/repository/android-2.1_r02-windows.zip http://dl-ssl.google.com/android/repository/android-2.2_r02-windows.zip http://dl-ssl.google.com/android/repository/android-2.3.1_r02-linux.zip http://dl-ssl.google.com/android/repository/android-3.0_pre_r01-linux.zip http://dl-ssl.google.com/android/repository/platform-tools_r02-windows.zip http://dl-ssl.google.com/android/repository/tools_r09-windows.zip http://dl-ssl.google.com/android/repository/docs-Honeycomb_pre_r01-linux.zip http://dl-ssl.google.com/android/repository/samples-Honeycomb_pre_r01-linux.zip http://dl-ssl.google.com/android/repository/samples-2.1_r01-linux.zip http://dl-ssl.google.com/android/repository/samples-2.2_r01-linux.zip http://dl-ssl.google.com/android/repository/samples-2.3_r01-linux.zip 2. 请使用下载工具下载到本地,并按如下映射关系解压缩到 SDK 下载器所 在目录,映射关系如下: android-1.5_r04-windows.zip platforms\android-3 android-1.6_r03-windows.zip platforms\android-4 android-2.0_r01-windows.zip platforms\android-5 android-2.0.1_r01-windows.zip platforms\android-6 6 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway android-2.1_r02-windows.zip platforms\android-7 android-2.2_r02-windows.zip platforms\android-8 android-2.3.1_r02-linux.zip platforms\android-9 android-3.0_pre_r01-linux.zip platforms\android-10 platform-tools_r02-windows.zip platforms-tools tools_r09-windows.zip tools docs-Honeycomb_pre_r01-linux.zip doc samples-Honeycomb_pre_r01-linux.zip samples\android-10 samples-2.1_r01-linux.zip samples\android-7 samples-2.2_r01-linux.zip samples\android-8 samples-2.3_r01-linux.zip samples\android-9 3. 如果要安装google api,请分析下图中的地址: http://dl-ssl.google.com/android/repository/addon.xml 下载自己需要的 Packages进行解压,方法同 1、2 下载列表为: http://dl-ssl.google.com/android/repository/google_apis-3-r03.zip http://dl-ssl.google.com/android/repository/google_apis-4_r02.zip 7 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway http://dl-ssl.google.com/android/repository/google_apis-5_r01.zip http://dl-ssl.google.com/android/repository/google_apis-6_r01.zip http://dl-ssl.google.com/android/repository/google_apis-7_r01.zip http://dl-ssl.google.com/android/repository/google_apis-8_r02.zip http://dl-ssl.google.com/android/repository/google_apis-9_r02.zip http://dl-ssl.google.com/android/repository/market_licensing-r01.zip http://dl-ssl.google.com/android/repository/usb_driver_r04-windows.zip 4. 映射关系为: google_apis-3-r03.zip add-ons\addon_google_apis_google_inc_3 google_apis-4_r02.zip add-ons\addon_google_apis_google_inc_4 google_apis-5_r01.zip add-ons\addon_google_apis_google_inc_5 google_apis-6_r01.zip add-ons\addon_google_apis_google_inc_6 google_apis-7_r01.zip add-ons\addon_google_apis_google_inc_7 google_apis-8_r02.zip add-ons\addon_google_apis_google_inc_8 google_apis-9_r02.zip add-ons\addon_google_apis_google_inc_9 market_licensing-r01.zip google-market_licensing usb_driver_r04-windows.zip usb_driver 5. 具体的目录结构如下图: 8 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 6. 解压完成后启动一下 SDK 下载器,检查是否安装成功,如下图: 9 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 注:由于小生在写这篇文章的时候,Android 刚出了 Android SDK Platform Honeycomb Preview, revision 1,但是却没有把 android-3.0_pre_r01-linux.zip 放在 http://dl-ssl.google.com/android/repository/android-3.0_pre_r01-linux.zip,所以暂时 无法下载安装这个版本的 Android SDK,但不影响 SDK 使用。请各位自行下载安 装。 四、 Eclipse 集成开发环境(IDE)搭建 现在开始 Eclipse IDE 及 Android Eclipse plugin 的安装和配置,这里使用的 Eclipse 版本为,eclipse-java-helios-SR1-win32.zip,请自行到 Eclipse 官方网站 (http://eclipse.org)上下载自己喜欢的版本,建议 3.4 以上版本。 我们使用的 Android Eclipse Plugin 是 ADT:Android Development Tools。 同 Android SDK 一样,分为在线安装和手动安装两种方式。 在线安装步骤如下: 1. 打开 Eclipse,选择菜单:Help->Install New Software... 10 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 2. 弹出“Available Software”对话框,点击“Add...”按钮 11 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 3. 弹出“Add Repository”对话框。 Name 中输入:ADT Location 中输入:https://dl-ssl.google.com/android/eclipse/,如果不支持 https 可有输入 http://dl-ssl.google.com/android/eclipse/ 如下图: 点击“OK”按钮。 4. 此时 Eclipse 会搜索指定 URL 的资源,如果搜索无误,会出现:Developer Tools 的复选框,选中此复选框。点击“Next”按钮。 12 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 5. 出现“Install Details”对话框。点击“Next”按钮。 13 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 6. 出现“Review Licenses”对话框,选择“I accept the terms of the license agreements”复选框。点击“Finish”按钮。 14 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 7. 进入下载及安装过程: 8. 过程中可能会出现“Security Warning”对话框,不用担心点击“OK”按 钮以继续安装。 15 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 9. 安装成功后,安装提示重启 Eclipse,即完成整个安装过程。 离线安装步骤如下; 1. 访问 http://androidappdocs.appspot.com/sdk/eclipse-adt.html 获取当前最新 版本的 ADT Eclipse 离线安装包,当前最新版本为:ADT 9.0.0,下载 地址为:http://dl.google.com/android/ADT_9.0.0.zip 2. 开始 Eclipse Plugin 的本地安装过程中,如下。由于整个过程跟在线安装 类似,具体不再详述。 五、 Eclipse ADT 配置 ADT 的 Eclipse Plugin 安装成功之后,开始 ADT 的配置,具体如下: 1. Eclipse 重启后,选择 Window > Preferences...,在打开的属性框,选择 Android,可以看到: 16 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 2. 在 SDK location 中输入你的 Android SDK 所在的目录,然后按 Apply 按钮 即可看到我们安装 SDK 包,如下图: 17 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 至此,Eclipse+ADT 的集成开发环境就安装配置完毕。 Android SDK 配置 ,即 Android Virtual Devices ,Android 虚 拟设 K and AVD Manager ,或者在 下 六、 这里介绍下新建 AVD。所谓 AVD 备,亦即嵌入式开发中常用的模拟器。 1. 在 Eclipse 中选择 Window-Android SD android-sdk-windows 文件夹中双击 SDK Manager.exe,可以看到类似如 界面: 18 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 注:这里可以看到小生已经创建过两个 AVD,其实这两个 AVD 并不是在本文下 载安装的 Android SDK 中配置的,但是由于所有的 AVD 配置信息都是存储在当 前用户的 home 中,如:C:\Documents and Settings\Administrator\.android\avd 。 因此,这里也可以看到。 2. 在弹出的 Android SDK and AVD Manager 对话框,选择 Virtual Devices, 按 new 按钮 创建虚拟设备,输入如下图所示: 19 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 其中: • Target:SDK 的类型 • SD card:SD 卡的大小 • Skin:显示屏的类型 3. 点击“Create AVD”按钮,如果安装成功,会在“Android SDK and AVD Manager”对话框中显示。 20 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 至此开发环境配置完成,接下来即可以进行 Android 上应用的开发。 七、 第一个 Android 应用(Hello,Android World!) 1. 新建项目:打开 Eclipse,选择 File > New > Project > Android Project,具 体输入如下图: 21 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 2. 点击“Next”,提示如下: 22 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 3. 这里仅为演示,不创建测试项目。直接点击“Finish”按钮即可。 23 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 4. 编辑 HelloAndroidWorld.java 文件,内容如下: package org.deaboway.test; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class HelloAndroidWorld extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView textView = new TextView(this); textView.setText("Hello Android World!"); setContentView(textView); } } 24 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 5. 运行 Android 项目:点击工具栏的运行按钮,或选择菜单:Run->Run,或 右键项目文件夹,会弹出“Run As”对话框,选择“Android Application”, 点击“OK”按钮。 6. 运行效果如下,AVD 加载的速度有些慢,需要耐心等待。 25 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 7. 同时,Eclipse 的控制台也会打印出运行时的一些相关信息,如下。 26 no Pain no Gain no Gavin 博客同步更新至:http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 更多相关文章,请访问: http://blog.sina.com.cn/deaboway http://blog.csdn.net/deaboway 以上两个 blog 同步更新。 27
本文档为【Android_SDK与Eclipse最新版开发环境搭建】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_262644
暂无简介~
格式:pdf
大小:1MB
软件:PDF阅读器
页数:0
分类:互联网
上传时间:2011-03-07
浏览量:24