参考:http://www.mkyong.com/android/attach-android-source-code-to-eclipse-ide/
解决方案
参考官方文档 Android source code article,我们需要使用“repo
” 下载并且编译全部源码来获得 “android.jar
“.
如果你觉得这活工作量太大,你可以使用一款Eclipse插件 “Android Source” 来获取 “android.jar
“. 参考 “Additional Eclipse plugins for Android“.
安装完毕后,理论上已经存在和新创建的Android项目将会自动关联Android源码.然而,天不遂人愿,‘自动'获取的愿望无法达成,需要手动设置。打开开“Android Source” 插件目录,应该在如下路径:
ECLIPSE_PATH\plugins\com.android.ide.eclipse.source_MAY_BE_VARY
目录
![android-source-code-to-eclipse-folder android source folders](https://i-blog.csdnimg.cn/blog_migrate/9df1f74ca55682dcd7f00d42b973d074.png)
- 14 – Android 4.0.1
- 10 – Android 2.3.4
- 9 – Android 2.3
- 8 – Android 2.2
- 7 – Android 2.1
- 6 – Android 2.0.1
- 4 – Android 1.6
- 3 – Android 1.5
每个目录中包含一个 “sources.zip“, 分别对应不同版本的Android.例如, 如果你使用 Android 2.3, 那么从 目录 “10“中抽取 “sources.zip”, 然后手动添加到Eclipse中
最终。。
![android-source-code-to-eclipse-result attach android source code to eclipse ide](https://i-blog.csdnimg.cn/blog_migrate/2c4f920dee7771dbcd055299246a7bb7.png)