最近用eclipse开发android程序,发现查看android sdk源码,报如下错误:
Source not found
The JAR of this class file belongs to container 'Android 2.0' which does not allow modification to source attachments on its entries
一般的SDK是不带源码的,就需要到网上去下载
repo init -u git://android.git.kernel.org/platform/manifest.git
repo sync
(www.android.git.kernel.org 是android源码网站)
我是从网上别人整理现成的下载的,版本是android 2.0 ,这个是下载地址:http://download.csdn.net/source/1873037
1. 在相应版本号的文件夹下新建文件夹sources(必须是这个名字)
比如:android-sdk-linux_x86/platforms/android-2.0/sources
2. 把下载下来的源文件放到sources文件夹下。
3. 重启eclipse
这样就可以查看源码了。
相关解决文章: http://android.opensourceror.org/2010/01/18/android-source/
http://blog.michael-forster.de/2008/12/view-android-source-code-in-eclipse.html
http://stuffthathappens.com/blog/2008/11/01/browsing-android-source-in-eclipse/
ps: 开始我的项目工程是建立在android-2.2的,为了加进源码,自己在android-sdk-linux_x86/platforms/android-8/ 下瞎弄,结果导致工程出错,错误如下:
android.hello.helloActivity does not extend android.app.Activity AndroidManifest.xml /hello line 8
不知道了是什么原因,现在也不想花时间去查了,就把工程改为2.0的了。