最近用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的了。