使用 ADT 和 SDK 管理器,将 android 源代码附加到 eclipse
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16432818/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using ADT and SDK manager, attach android source code to eclipse
提问by tbkn23
After installing ADT, I used SDK Manager to download the source codes for the latest android API. Now when I run the Eclipse version that was provided with the ADT, I still can't see the android source codes.
安装 ADT 后,我使用 SDK Manager 下载了最新 android API 的源代码。现在,当我运行与ADT 一起提供的Eclipse 版本时,我仍然看不到android 源代码。
Is there a simple way to fix this?
有没有简单的方法来解决这个问题?
回答by Sam
Open SDK Manager-->install source under api(i.e Android 4.0)
打开SDK Manager-->在api下安装源码(即Android 4.0)
if You got No sources attached then click the button, then choose the Directory
如果您没有附加来源,则单击按钮,然后选择目录
e.g: D:\Android\android___sdk\sources\android-17\ ---> this my android sdk location
例如:D:\Android\android___sdk\sources\android-17\ ---> 这是我的 android sdk 位置
Depend upon your android installation directory choose accordingly.
根据您的 android 安装目录进行相应选择。
回答by KingAlex1985
After downloading the Sourcecode by useing the "Android SDK Manager", you have to change the settings in your eclipse-porject.
使用“Android SDK 管理器”下载源代码后,您必须更改 eclipse 项目中的设置。
At first, just have a look where the Sourcecode has been downloaded. In my case (useing Windows 8) its here: "C:\adt-bundle-windows-x86_64-20130219\sdk\sources\android-17"
首先,看看源代码在哪里下载。在我的情况下(使用 Windows 8)它在这里:“C:\adt-bundle-windows-x86_64-20130219\sdk\sources\android-17”
- Now go into Eclipse.
- Open the "Properties" of the project (right click on the project-folder and click on "Properties").
- On the left side click on "Java Build Path" and then click on the tab-page "Libraries".
- Next you click on the right side on the button "Add External Class Folder...".
- Select the folder where you find the sourcecode. In my case its the folder "android-17" of the path "C:\adt-bundle-windows-x86_64-20130219\sdk\sources\android-17".
- Commit / close all windows with ok. (Maybe you should restart eclipse.)
- 现在进入Eclipse。
- 打开项目的“属性”(右键单击项目文件夹并单击“属性”)。
- 在左侧点击“Java Build Path”,然后点击标签页“Libraries”。
- 接下来,单击右侧的“添加外部类文件夹...”按钮。
- 选择找到源代码的文件夹。在我的情况下,它是路径“C:\adt-bundle-windows-x86_64-20130219\sdk\sources\android-17”的文件夹“android-17”。
- 用 ok 提交/关闭所有窗口。(也许您应该重新启动 eclipse。)
And now you can see/read the Android-Sourcecode. (But only in the project which you have choosen before.)
现在您可以查看/阅读 Android 源代码。(但仅限于您之前选择的项目。)
回答by SQ9MCP
Previous answers are great but here you have a complete resource by Lars Vogel who address this question. I hope it may be useful as well as it was for me.
以前的答案很好,但在这里你有 Lars Vogel 的完整资源,他解决了这个问题。我希望它对我有用。
回答by averasko
First, you need to download them. Use Android SDK Manager -> Android X.Y.Z (API A) -> Sources for Android SDK.
首先,您需要下载它们。使用 Android SDK Manager -> Android XYZ (API A) -> Sources for Android SDK。
Then, you need to attach the folder with the sources the next time you browse there: /sources/android-A
然后,您需要在下次浏览时附加带有源的文件夹:/sources/android-A
回答by ultraon
I found this for me:
我为我找到了这个:
For main lib: android.jar: src: sdk/sources/android-19 doc: sdk/docs/reference/
对于主库:android.jar:src:sdk/sources/android-19 doc:sdk/docs/reference/
For support lib: android-support-v4.jar: (before this we should add android-support-v4.jar like external jar (Project Properties -> Java Build Path -> Libraries, then in Tab ‘Order and Export' pull up this library before Android Private Libraries)) src: sdk/extras/android/support/v4/src/java doc: http://developer.android.com/reference/android/support/v4/app/package-summary.html(not sure)
对于支持库:android-support-v4.jar:(在此之前,我们应该像外部 jar 一样添加 android-support-v4.jar(项目属性 -> Java 构建路径 -> 库,然后在 Tab 'Order and Export' 中拉起这个库在 Android 私有库之前)) src: sdk/extras/android/support/v4/src/java doc: http://developer.android.com/reference/android/support/v4/app/package-summary.html(没有把握)