Java JAR 文件 C:\sdk\platforms\android-18\android.jar 没有源附件。您可以通过单击下面的附加源来附加源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19189505/
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
The JAR file C:\sdk\platforms\android-18\android.jar has no source attachment. You can attach the source by clicking attach source below
提问by HelloMojo
I'm getting an error stating:
我收到一条错误消息:
The JAR file C:\sdk\platforms\android-18\android.jar has no source attachment. You can attach the source by clicking attach source below.
However I've clicked the attach source button and added C:\sdk\platforms\android-17\android.jar and then it simply gives me:
但是我点击了附加源按钮并添加了 C:\sdk\platforms\android-17\android.jar 然后它只是给了我:
Source not found. The source attachment does not contain the source for the file Activity.class. You can change the source attachment by clicking Change Attached Source below.
回答by Aaron M
You need to attach a second jarfile containing the source code (.java) files for the given library. As in ppeterka's comment, this will usually be named something like "android-src.jar". In your example, you actually used a different version of the binary jarfile, which won't contain source files.
您需要附加包含给定库的源代码 (.java) 文件的第二个 jarfile。在 ppeterka 的评论中,这通常会被命名为“android-src.jar”。在您的示例中,您实际上使用了不同版本的二进制 jarfile,它不包含源文件。
Specifically for obtaining the Android SDK sources, the Android SDK Manager tool should allow you to download them easily: http://developer.android.com/sdk/installing/adding-packages.html
专门为获取 Android SDK 源代码,Android SDK Manager 工具应该允许您轻松下载它们:http: //developer.android.com/sdk/installing/adding-packages.html
Once those are downloaded, you'll need to find the path to the right jar/zip file(s) and reattach the correct source.
下载这些文件后,您需要找到正确的 jar/zip 文件的路径并重新附加正确的源。
回答by inman320
First make sure that you've downloaded the source files for the version of android that you're using in the project via the Android SDK Manager: http://developer.android.com/sdk/installing/adding-packages.html
首先确保您已经通过 Android SDK 管理器下载了您在项目中使用的 android 版本的源文件:http: //developer.android.com/sdk/installing/adding-packages.html
Then right-click on your project and choose properties, pick "Java Build Path" from the left menu, pick the "Libraries" tab on the right, click to expand "Android X.X.X", click to expand "android.jar", and then double-click the "Source attachment:" item.
然后右键单击您的项目并选择属性,从左侧菜单中选择“Java Build Path”,选择右侧的“Libraries”选项卡,单击展开“Android XXX”,单击展开“android.jar”,然后然后双击“源附件:”项目。
In the pop-up, choose the "External Location", click "External Folder", and browse to your android-sdk/sources/android-xx that is appropriate for the "Android X.X.X" selected earlier. Choose OK to close the dialogs, and you should be set!
在弹出的窗口中,选择“外部位置”,点击“外部文件夹”,然后浏览到适合之前选择的“Android XXX”的android-sdk/sources/android-xx。选择确定关闭对话框,你应该设置!