在Eclipse中开发android的应用程序时,有时想查看函数的内部实现,但是当在函数上点击ctrl和鼠标左键的时候,

往往出现如下提示:

Class File Editor

Source not found

The JAR of this class file belongs to container 'Android' which does not allow modifications to source attachments on its entries.

因此按照如下操作添加对应的源代码:

选择workspace 里面的项目,点击右键--->Build Path-->configure build path -->liberaries-->选择一个jar包--->点击左侧的展开三角按钮--->

展开后选择Source attachment --->点击右侧的 Edit 按钮--->弹出对话框,并选择External File---->找到指定的源文件压缩包。或者可使用外部源文件目录。点击OK。

进去以后发现还是不能查看,同样的提示!

仔细读英文的后半部分,在libs中直接引用的第三方jar包不让其做任何修改。包括添加源文件参看。

因此在android工程下新建一个lib目录,将jar包从libs转移到lib中。然后重复以上过程。

结果就可以查看了!不过一运行你的程序,马上报错无法找到class的错误。 = =! 死胡同了~

看来只能将第三方jar放到libs了。

有的牛人这样解决了:

In order to link thesources and javadocto a .jar library that is automatically linked by Eclipse you have to do the following.

  1. Place all three .jar files in the libs folder.
  2. Create.propertiesfile in the libs folder with the name of the library .jar (see example).
  3. Specify the relative paths to the sources and javadoc .jar in the .properties file.
  4. Closeand re-open the Eclipse project! Optionally refresh the project.
  5. Select an object of the linked library in the source code.
  6. Open the Javadoc view in Eclipse to check the documentation (see screenshot).
  7. Open the source code declaration (default shortcut:F3) of the selected object.

Example:GSON library

/libs/gson-2.2.2.jar
/libs/gson-2.2.2.jar.properties
/libs/gson-2.2.2-javadoc.jar
/libs/gson-2.2.2-sources.jar

Contents of gson-2.2.2.jar.properties

src=gson-2.2.2-sources.jar
doc=gson-2.2.2-javadoc.jar

  

You can of course move the javadoc and sources .jar into other folders and specify relative paths. That's up to you.

但是遗憾的是,弄了半天都没能解决。可能也跟我用的第三方的jar包不规范的原因,而且我没有doc文件。


最终,我想到了一个解决办法:

新建一个lib目录

将需要的jar包全部拷贝到该目录下

依次对每个jar包执行 上面绿色 部分操作

完成后右键lib目录,点击build path--> use as source folder

即可解决查看源码的问题,也可使程序正常执行。


From:http://blog.csdn.net/leon90dm/article/details/8521939

更多相关文章

  1. android开发 列表显示(ListView)
  2. android2.2资源文件详解4--menu文件夹下的菜单定义
  3. ListItem更改背景色
  4. 在android平台上编译libpcap-0.9.8 和 jnetpcap-1.2.rc1
  5. android studio的问题整理(如何删除模块(Module))
  6. 在android平台上编译libpcap-0.9.8 和 jnetpcap-1.2.rc1
  7. android studio调试c++代码
  8. android三级联动、四级联动(地区选择)
  9. android Button组件的属性和方法

随机推荐

  1. Android中List、Set、Map数据结构详解
  2. 转 android launch flow
  3. 在Linux中运行Android软件
  4. 从Android到Swift iOS开发:语言与框架对比
  5. android LinearLayout添加分隔线
  6. Android(安卓)SearchView 搜索框
  7. golang开发android应用(二) - go语言生成an
  8. android 版本更新和下载安装 适配android
  9. android菜鸟学习笔记16----Android项目打
  10. Android系列之Wifi定位