使用eclipse做Android开发时,想查看或追溯一些系统api时,往往会出现:
The JAR /home/xxx/.../android.jar has no source attachment.
android you can attach the source by clicking attach source below:
于是在网上找到一种的方法,记录下:
一、在eclipse上,选择 Window->Android SDK Manager,找到已经安装的sdk版本。例如Android 4.2.2(API 17),找到 "Sources for Android SDK",如果已经安装就不管了,若没安装,选上并安装。
二、再回到android you can attach the source by clicking attach source below页面. 点击 "Attach Source" ,选择 External Location,再点击 external folder.找SDK安装目录并选择 /home/me/android-sdks/sources/android-17
(android-17是SDK安装版本,每个人安装的可能不同)。
attention:
If using SDK manager then the source shall need to be bundled into a zip file. Go to C:\Program Files (x86)\Android\android-sdk\sources. Right click on any of the API level folder and zip it using any zip utility. You need to provide the path to this zip file from the Browse option when you clicked on “Attach Source” button.