Android 无法查看外部依赖jar的源码的问题
2015-03-24 11:45
288 查看
在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 the sources and javadoc to a .jar library that is automatically linked by Eclipse you have to do the following.
Place all three .jar files in the libs folder.
Create
in the libs folder with the name of the library .jar (see example).
Specify the relative paths to the sources and javadoc .jar in the .properties file.
Close and re-open the Eclipse project! Optionally refresh the project.
Select an object of the linked library in the source code.
Open the Javadoc view in Eclipse to check the documentation (see screenshot).
Open the source code declaration (default shortcut: F3) of the selected object.
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
即可解决查看源码的问题,也可使程序正常执行。
上面粗体字方法,亲测可用。
3楼 youz1976 2014-11-27 23:55发表 [回复] [引用] [举报]
想看到百度地图的源代码,按这种方式试了还是不可以
2楼 l996243623 2014-05-08 00:27发表 [回复]
在工程的libs目录下新建一个.properties文件,命名为android-support-v4.jar.properties 里面写上
src=D:\\Program Files\\adt-bundle-windowsx-86\\sdk\\extras\\android\\support\\v4\\src这是源码的目录(这是我的源码路径),windows系统要加双反斜杠,Linux不用,就OK了。
Re: cyq1028 2014-07-25 14:42发表 [回复]
回复l996243623:太谢谢你的回复了,原来我用的单斜杠,太坑了!
1楼 kinkabrain 2014-01-16 20:11发表 [回复]
对于我来说,上面的方式都不行,最后是去修改工程目录下的.classpath 文件,其中 <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/> 这两行的顺序很重要!
然后在第二行添加jar包对应的源工程:
<classpathentry kind="lib" path="libs/mysdk.jar" sourcepath="/mysdk"/>
往往出现如下提示:
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 the sources and javadoc to a .jar library that is automatically linked by Eclipse you have to do the following.
Place all three .jar files in the libs folder.
Create
.propertiesfile
in the libs folder with the name of the library .jar (see example).
Specify the relative paths to the sources and javadoc .jar in the .properties file.
Close and re-open the Eclipse project! Optionally refresh the project.
Select an object of the linked library in the source code.
Open the Javadoc view in Eclipse to check the documentation (see screenshot).
Open the source code declaration (default shortcut: F3) of the selected object.
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
即可解决查看源码的问题,也可使程序正常执行。
上面粗体字方法,亲测可用。
3楼 youz1976 2014-11-27 23:55发表 [回复] [引用] [举报]
想看到百度地图的源代码,按这种方式试了还是不可以
2楼 l996243623 2014-05-08 00:27发表 [回复]
在工程的libs目录下新建一个.properties文件,命名为android-support-v4.jar.properties 里面写上
src=D:\\Program Files\\adt-bundle-windowsx-86\\sdk\\extras\\android\\support\\v4\\src这是源码的目录(这是我的源码路径),windows系统要加双反斜杠,Linux不用,就OK了。
Re: cyq1028 2014-07-25 14:42发表 [回复]
回复l996243623:太谢谢你的回复了,原来我用的单斜杠,太坑了!
1楼 kinkabrain 2014-01-16 20:11发表 [回复]
对于我来说,上面的方式都不行,最后是去修改工程目录下的.classpath 文件,其中 <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/> 这两行的顺序很重要!
然后在第二行添加jar包对应的源工程:
<classpathentry kind="lib" path="libs/mysdk.jar" sourcepath="/mysdk"/>
相关文章推荐
- Android 无法查看外部依赖jar的源码的问题
- Android 无法查看外部依赖jar的源码的问题
- Android 无法查看外部依赖jar的源码的问题
- The JAR of this class file belongs to container 'Android Private Libraries' Android查看外部依赖jar的源码问题解
- Android之查看外部依赖jar的源码
- 点击查看外部依赖jar的源码报找不到 android private libralies does not allow modifications to source
- Android之查看外部依赖jar的源码_android private libralies does not allow modifications to source
- Android查看外部依赖jar的源码,如android-support-v4.jar
- Android之查看外部依赖jar的源码_android private libralies does not allow modifications to source
- Android private Libraires 无法查看源码的问题
- Android Eclipse Libs 的 jar 源码查看 (或者新版本ADT无法查看jar的源码)
- android引入外部项目点击不能查看源码问题
- 解决谷歌为Android系统提供的支持库android-support-v4。jar不能绑定查看源码的问题
- 关于Android多项目依赖在Eclipse中无法关联源代码的问题解决 (android dependencies 源码)
- Android之查看外部依赖jar的源代码_android private libralies does not allow modifications to source
- Android查看jar包源码问题
- 解决 Android 26 无法查看系统源码的问题
- 解决 Android 26 无法查看系统源码的问题
- Android Studio 查看FrameWork层源码(例如:PhoneWindow) android.jar
- 通过maven查看依赖jar的源码