一. 搭建环境
下载android sdk 和eclipse,配置相应的环境变量
1.eclipse 安装插件
a. svn-plugin - http://subclipse.tigris.org/update_1.6.x
b. ADT Plugin - https://dl-ssl.google.com/android/eclipse/
二. 关联android源码
打开Eclipse中Open the Android SDK Manager , 点击安装自己需要的版本的SDK Platform以及相应的文档等;
在这里我们可以看到只有在Android 4.0版本以上的才有选项Sources for Android SDK, 这就是Android对应版本的API源码。安装完成后会在你所安装Android SDK的目录中,如C:\Program Files\Android\android-sdk\sources\android-16,android-16就是Android 4.1版本对应的API源码。
接下来就是配置了Android工程关联其API源码 了:
右击目标工程,Build Path -> Configure Build Path -> Library选项下 -> Android 4.1 -> android.jar -> Source attachment --> Edit --> External Folder 选择这个文件目录C:\Program Files\Android\android-sdk\sources\android-16,android-16即可。
另外,Android 4.0 以下的,需要下载对应版本的Android API源码包,然后
右击目标工程,Build Path -> Configure Build Path -> Library选项下 -> Android 4.1 -> android.jar -> Source attachment --> Edit --> External File 选择下载好的源码压缩包即可。
附:
下载教程。确保你已经安装了git jdk python等,操作系统环境为Linux。
1.创建bin目录,并加入到PATH
$ mkdir ~/bin
$ PATH=~/bin:$PATH
2.下载repo到刚刚创建的bin目录,并设置权限为可执行。
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
3.创建Android源代码存放目录并进入到该目录
$ mkdir Android-4.0.0_r1
$ cd Android-4.0.0_r1
4.初始化Android4.0.1的Git库
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
5.最后执行开始同步下载
$ repo sync
来源:http://blog.youkuaiyun.com/leichelle/article/details/7980011
三. 关联本地android api docs
project->properties->java build path->librarys->android 4.2->android.jar->javadoc location
android-sdk-windows/docs/reference/点browse,找到本地的D:\android-sdk-windows\docs\reference
详细请看http://blog.youkuaiyun.com/lyh7736362/article/details/6361537