使用Eclipse 既可以查看Android 源码,也可以基于源码调试(Application)部分,非常好用。
开发环境:Windows7 上使用 Eclipse (下载这个Classic 版本的http://www.eclipse.org/downloads/packages/eclipse-classic-372/indigosr2 , 如果你不知道JDK装的是64还是32位的,选择32位的Eclipse ),远程访问服务器Ubuntu上的代码。
这种情况下查看以及调试Android 的方法在好多地方都可以找到,不过原始来源都是google 的官方文档:
http://source.android.com/source/using-eclipse.html
这里说的是查看基于Android 源码建立开发环境,如果只是基于SDK 开发,可能要看这里:https://developer.android.com/tools/sdk/eclipse-adt.html
1.先编译源码: http://source.android.com/source/building.html
cd /path/to/android/root
make
2. 拷贝.classpath到android源码的根目录 :
Eclipse needs a list of directories to search for Java files. This is called the "Java Build Path" and can be set with the.classpath
file. We have a sample version to start you off.
cd /path/to/android/root cp development/ide/eclipse/.classpath . chmod u+w .classpath
3.增大Eclipse JVM Memmory 设置:
修改eclipse.ini 文件, 在Eclipse安装目录。
-Xms128m -Xmx512m -XX:MaxPermSize=256m
These settings set Eclipse's minimum Java heap size to 128MB, set the maximum Java heap size to 512MB, and keep the maximum permanent generation size at the default of 256MB.
4.启动Eclipse,新建工程(Java 工程),选择“Create project from existing source”,目录填入Android源码根目录, wait 。。。.
5.Eclipse Formatting。
android 源码里 development/ide/eclipse
下两个文件可以帮助规范代码的格式(与Android原生的格式一致.
-
Select Window > Preferences > Java > Code Style.
-
Use Formatter > Import to import
android-formatting.xml
. -
Organize Imports > Import to import
android.importorder
.