本人刚开始玩Android,成长阶段请多指教

学习时发现在Eclipse中尝试查看SDK的源代码时提示NotFound,在google上查到了一个方法,大家有需要的试下


1.下载http://www.digginmobile.com/android.asp上的源码
2.将那个源码文件解压,并在你的SDK安装目录里面新建一个文件夹,取名为“sources”,把之前解压得到的所有文件都复制到新建的“sources”文件夹里面。(D:\android-sdk-windows-1.5_r1\platforms\android-1.5这个是我的SDK路径,就是在这个目录下面建一个名为“sources”文件)

完成上面的步骤后,就可以在eclipse中查看SDK的代码了

不过俺发现有些源码明明在,却还是关联不上,不过大多数能够直接看了,大家有遇到过这种情况的吗~请多指教

--------

2.android安装
▼在各个版本的sdk下面创建新文件夹sources,如下
android_sdk_installation_folder\platforms\android-1.5\sources
android_sdk_installation_folder\platforms\android-1.6\sources
android_sdk_installation_folder\platforms\android-2.0\sources

▼把下载后的zip解压缩到上面的sources下面,重新启动eclipse即可查看。

------

1,把下载好的Android 源码 解压缩到文件夹下,可以起名sources
2,eclipse --> project--> properties 下找 java build path,其中选择libraries,点击Android 1.6,点击andorid.jar。下面有个 sources attachment。点击编辑,点击external folder,把刚才解压缩的文件夹选上。
3,ok了


我把我本地的源码放在115上了,地址是:

1.6源码 http://u.115.com/file/f99339eb89

2.2源码 http://u.115.com/file/f9aadee81

---------------------------------------------------------------

获取Android SDK 源代码并在Eclipse中关联查看的方法(for sdk2.3)

获取Android的Java源代码并在Eclipse中关联查看的最新方法作者:lizongbo发表于:01:59. 星期六, 一月 1st, 2011
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明。
http://618119.com/archives/2011/01/01/201.html

在Google搜索“AndroidEclipse 源代码”得到的结果并不合适,因为Google的EclipseAndroid开发插件已经更新到了ADT 8.0.1.相应的lib关联java源代码的方式也变了。
以下是获取Android的Java源代码并在Eclipse中关联的最新操作方法和步骤:
1.首先下载Android的SDK安装文件:http://dl.google.com/android/android-sdk_r08-windows.zip
然后解压到:E:\Java\android\android-sdk-windows,运行目录中的SDK Manager.exe,下载好Android不同版本的API包。

2.然后下载或在线安装Eclipse插件ADT,
安装包地址为:http://dl.google.com/android/ADT-8.0.1.zip
在线安装地址:https://dl-ssl.google.com/android/eclipse/
来源:ttp://developer.android.com/sdk/eclipse-adt.html

2.ADT插件安装好之后,下载我已经打包好的Android2.3(gingerbread)的java源代码压缩包:
下载地址:http://lizongbo.googlecode.com/files/android_gingerbread_javasrc.zip
来源:http://code.google.com/p/lizongbo/downloads/list
下载后复制到E:\Java\android\javasrc。

3.Android的Java源代码压缩包下载好之后,在Eclipse中设置好SDK配置:
操作步骤为:主菜单->Window–>Preferences–>选择Android,SDK Location设置为:E:\Java\android\android-sdk-windows,然后点右下角的Apply来生效。

4.开始进行关联Android的源代码,在Eclipse中新建一个Android工程,选中工程,主菜单 –>Project–>Properties–>选择Android,Project Build Target选中Android2.3。
然后再点左边的“JavaBuild Path”,切换到 Libraries 面板,展开 Android2.3 这个lib,点击android.jar的Source attachment,再点Edit.在对话框中点“External File”,选择E:/Java/android/javasrc/android_gingerbread_javasrc.zip,点OK进行确认。这样就把Android的java代码关联好了。

5.在同一个工程中,选中工程,主菜单–>Project–>Properties–>选择Android,Project Build Target分别选择Android1.5,Android1.6,Android2.01,Android2.1- update1,Android2.2,按上面第四步的操作重复设置关联。
以后在任何Android工程里按住Ctrl用鼠标点击Java类名都可以浏览到对应的java源代码。
Android各个版本对应的源代码为:
Android1.5对应android_cupcake_javasrc.zip
Android1.6对应android_donut_javasrc.zip
Android2.01和Android2.1-update1对应的是android_eclair_javasrc.zip
Android2.2对应android_froyo_javasrc.zip
Android2.3对应android_gingerbread_javasrc.zip

6.在Eclipse配置好源代码关联之后之后的信息会存储在:
E:\lizongbo\workspacenew\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes\properties.index
E:\lizongbo\workspacenew\.metadata\.plugins\org.eclipse.jdt.core\variablesAndContainers.dat

同时记录Android的java源代码压缩包制作方法如下:
1.先在远程的UbuntuLinux服务器(是Linode VPS)上安装以下组件(JDK1.6已经安装好了):
sudo apt-get installgit-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
信息来自Android官方:http://source.android.com/source/download.html
2.运行 sudo apt-get install lib32readline5-dev
3.安装Repo脚本:
我懒得配PATH了,于是直接安装到了/usr/local/bin。
[email protected]:~/bin# cd /usr/local/bin
[email protected]:/usr/local/bin# ls
geoip-lookup
[email protected]:/usr/local/bin# curlhttp://android.git.kernel.org/repo>/usr/local/bin/repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 17412 100 17412 0 0 27517 0 –:–:– –:–:– –:–:– 31148
[email protected]:/usr/local/bin# chmod a+x /usr/local/bin/repo
注意在下载该脚本的时候,可能会遇到服务器出错,下载的内容不对,运行命令的时候会提示错误“syntax error near unexpected token `newline’”。
[email protected]:/usr/local/bin# repo init -ugit://android.git.kernel.org/platform/manifest.git-b cupcake
/usr/local/bin/repo: line 1: syntax error near unexpected token `newline’
/usr/local/bin/repo: line 1: `<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>’
[email protected]:/usr/local/bin# more repo
<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
[email protected]and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
从内容看是服务器出错了,因此需要重新下载脚本.
4.建立mydroid目录,按代码分支下载对应版本的Android完整的源代码,比如下载Android2.3的代码:
[email protected]:~/mydroid# mkdir gingerbread
[email protected]:~/mydroid# cd gingerbread/
[email protected]:~/mydroid/gingerbread# repo init -ugit://android.git.kernel.org/platform/manifest.git-b gingerbread
[email protected]:~/mydroid/gingerbread# repo sync
Android1.5的代码分支:
[email protected]:~/mydroid/cupcake# repo init -ugit://android.git.kernel.org/platform/manifest.git-b cupcake
[email protected]:~/mydroid/cupcake# repo sync
Android1.6的代码分支:
[email protected]:~/mydroid/donut# repo init -ugit://android.git.kernel.org/platform/manifest.git-b donut
[email protected]:~/mydroid/donut# repo sync
Android2.0.1和2.1的代码分支:
[email protected]:~/mydroid/eclair# repo init -ugit://android.git.kernel.org/platform/manifest.git-b eclair
[email protected]:~/mydroid/eclair# repo sync
Android2.2的代码分支:
[email protected]:~/mydroid/froyo# repo init -ugit://android.git.kernel.org/platform/manifest.git-b froyo
[email protected]:~/mydroid/froyo# repo sync

如果遇到代码下载速度太慢,可以指定hosts,hosts配置不住为:
[email protected]:~/mydroid/gingerbread/.repo/projects# nslookup
>android.git.kernel.org
Server: 72.14.188.5
Address: 72.14.188.5#53
Non-authoritative answer:
android.git.kernel.org canonical name =android.git.geo.kernel.org.
android.git.geo.kernel.org canonical name =android.git.us.kernel.org.
Name:android.git.us.kernel.org
Address: 149.20.20.141
Name:android.git.us.kernel.org
Address: 204.152.191.45
> exit

[email protected]:/etc# vi hosts
204.152.191.45android.git.us.kernel.org
204.152.191.45android.git.kernel.org

网上有文章介绍使用提取java文件并打包的pytho脚本可以生成源代码包,参考:

http://android.opensourceror.org/2010/01/18/android-source/

http://blog.michael-forster.de/2008/12/view-android-source-code-in-eclipse.html
Python下载地址:http://www.python.org/ftp/python/2.6.6/python-2.6.6.msi
但是在Android2.2和Android2.3的代码里,Android写一了一些mock的类,比如android.webkit.WebView,使用python脚本打包的话,会把mock的源代码打进去,而不是真正的源代码,
因此我根据python脚本写了个java程序来提取java文件过滤冗余的java代码并打包。
生成的java源代码压缩:android_cupcake_javasrc.zip,android_donut_javasrc.zip,android_eclair_javasrc.zip,android_froyo_javasrc.zip,android_gingerbread_javasrc.zip
目前在code.google.com上传了android_gingerbread_javasrc.zip,欢迎下载。

以下是各版本的Androidjavasource 下载地址:

Android2.3:http://lizongbo.googlecode.com/files/android_gingerbread_javasrc.zip

Android1.5:http://lizongbo.googlecode.com/files/android_cupcake_javasrc.zip
Android1.6:http://lizongbo.googlecode.com/files/android_donut_javasrc.zip
Android2.1:http://lizongbo.googlecode.com/files/android_eclair_javasrc.zip
Android2.2:http://lizongbo.googlecode.com/files/android_froyo_javasrc.zip

新年快乐!

更多相关文章

  1. 没有一行代码,「2020 新冠肺炎记忆」这个项目却登上了 GitHub 中
  2. Android中与ViewRoot相关的一些概念
  3. Android(安卓)Aspectj在Library中的使用说明
  4. Android5.1.1源码 - zygote fork出的子进程如何权限降级
  5. 自定义对象的监听方式
  6. Android(安卓)为点击事件添加震动效果
  7. Android(安卓)M 动态权限获取
  8. Flutter混合开发踩坑指北
  9. android AIDL RPC 机制

随机推荐

  1. 【Unity3D】Unity3D与Android的交互通信(A
  2. Android(安卓)Studio 简单介绍和使用问题
  3. android开发资源合集
  4. Android: TextView常用属性的用法详解
  5. [置顶] 对Android(安卓)MVVM的理解
  6. Android中MPAndroidChart自定义绘制最高
  7. 【Android开发】基本组件-图像视图
  8. 在eclipse的android工程里引用android sd
  9. android studio 完整安装教程,已完全实践
  10. android之activity学习