欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Eclipse中查看android工程代码出现"android.jar has no source attachment"的解决方案

程序员文章站 2024-03-12 10:52:20
问题描述 source not found the jar file d:\.....\sdk\platforms\android-17\android.jar has...

问题描述

source not found

the jar file d:\.....\sdk\platforms\android-17\android.jar has no source attachment.

Eclipse中查看android工程代码出现"android.jar has no source attachment"的解决方案

提示就是找不到android.jar对应的source code

解决办法:

由于我的工程创建时选择的target sdk 和 compile with选项 均为android4.2.2,对应的api是17,因此就是eclipse找不到android api 17中的android.jar的源代码。
1. 使用sdk manager下载4.2.2版本的sources for android sdk

Eclipse中查看android工程代码出现"android.jar has no source attachment"的解决方案
Eclipse中查看android工程代码出现"android.jar has no source attachment"的解决方案

以本机为例下载后的目录为:
d:\adt-bundle-windows-x86_64-20130522\sdk\sources\android-17

2. 添加源代码

点击出错窗口中的attach source...按钮,然后

Eclipse中查看android工程代码出现"android.jar has no source attachment"的解决方案

找到
d:/adt-bundle-windows-x86_64-20130522/sdk/sources/android-17
点击ok后源代码就显示出来了

================

2013.10.9更新:

可能是使用了android4.3(api 18)新的api,今天使用eclipse/adt bundle出现了

the source attachment does not contain the source for the file *.class 的问题,而指定的源代码目录是没有问题的,问题竟然是编码问题。

上图中的encoding选项修改为utf-8,问题解决。

以上就是本文的全部内容,希望对大家的学习有所帮助。