Android SDK 源代码关联Eclipse

Eclipse中关联SDK源码,方便阅读熟悉底层源码。

一、下载android2.3.3源码。

http://rgruet.free.fr/public/android-2.3.3-gingerbread-src.zip

二、在SDK目录下新建sources目录,并把下载好的zip包解压在sources里。

以我本机的为例,在C:\Program Files\Android\android-sdk\platforms\android-10下新建sources;

把android-2.3.3-gingerbread-src.zip拷贝到sources下,解压到当前目录。

三、修改source.properties相关配置。

以我本机为例C:\Program Files\Android\android-sdk\platforms\android-10\source.properties 修改四个地方,修改后为

[html] view plain copy
  1. ### Android Tool: Source of this archive.  
  2. #Sun Mar 04 01:51:13 CST 2012  
  3. Layoutlib.Api=4  
  4. Layoutlib.Revision=0  
  5. Pkg.Desc=Android SDK Platform 2.3.3._r2  
  6. Pkg.UserSrc=true ## add by lu7kang -----------1  
  7. Archive.Arch=ANY  
  8. Platform.Version=2.3.3  
  9. ##Pkg.DescUrl=http\://developer.android.com/sdk/  ## delete by lu7kkang---------------2  
  10. Platform.MinToolsRev=8  
  11. Archive.Os=ANY  
  12. ##Pkg.SourceUrl=https\://dl-ssl.google.com/android/repository/repository-5.xml ## delete by luqk ----------3  
  13. Pkg.Revision=2  
  14. AndroidVersion.ApiLevel=10  
  15. Pkg.SourceUrl=sources ## add by lu7kang ---------4  


四、重启eclipse,在android工程里,按ctrl点击类名可以阅读到android2.3的源码了。

方法二:

         将源码放在sources 文件夹下,无需解压。 按住Ctrl ,点击android SDK 类,进入找不到源码页面, 再点击 Change Attached Source,然后点击 External File,  找到对应的源码压缩文件, OK了。

猜你喜欢

转载自892848153.iteye.com/blog/1880430