Google’s Android SDK
includes android.jar
, which contains the Android
public API class files. They also provide an Eclipse plugin
,
making it quite easy to get started. What you will not find, however, is androidSrc.jar
, so when you try to look at
Android SDK source code in Eclipse, you get something like this:
Open
Source to the Rescue!
Earlier this month,
Google released the source code — all of it — and by the way, it’s HUGE.
Anyway, to browse source in Eclipse, you need to visit http://source.android.com/
and follow
their instructions to pull everything down using Git. Set aside an evening to
do this, because having the full source makes it infinitely easier to
understand how the SDK works.
Attaching
to Eclipse…Not So Fast, Buddy
Now that you have
the source, you can tell Eclipse where to find it. I tried right-clicking on android.jar
and selecting Properties
, but am greeted with this screen:
Hmm…”The current
class path entry belongs to container ‘Android Library’ which does not allow
user modifications to source attachments on its entries.” This really threw me
for a loop. I generally use IDEA, so I was really stumped by this. So, I dug
into the source code to find out a solution.
Examining
the Source
When you download
the Android source, you get EVERYTHING. This includes the OS, the Dalvik VM,
the Eclipse Plugin, the public SDKs, etc.
In the
com.android.ide.eclipse.adt.project.internal package, I found
a class named
AndroidClassspathContainerInitializer.java. This has
the following code:
IPath android_src =
new Path(AdtPlugin.getOsAbsoluteAndroidSources());
OK, fine. So looking
inside AdtPlugin.java:
/** Returns the
absolute android sources path in the sdk */
public static String
getOsAbsoluteAndroidSources() {
return getOsSdkFolder() + getOsRelativeAndroidSources();
}
/** Returns the
android sources path relative to the sdk folder */
public static String
getOsRelativeAndroidSources() {
return AndroidConstants.FD_ANDROID_SOURCES;
}
And finally inside
AndroidConstants.java:
public static final
String FD_ANDROID_SOURCES = "sources";
I win!
Solution
#1
Based on the above
analysis, you need to create a directory named “sources” inside your Android
SDK installation. So right next to your android.jar
,
create a sources
directory.
Now that you have
this directory, you can find the appropriate source directories in the Android
sources that you pulled from Git. Google’s checkout directions suggest a
directory named ‘mydroid’, so I’ll use that here. The public SDK source is
found in mydroid/frameworks/base/core/java
.
Under that folder you’ll find an android
directory, which should be copied (or symlinked) over to the sources
directory in your SDK installation.
You’ll have to do
some hunting around to find all of the source code, it’s kind of sprinkled all
over the place in the mydroid
directory
tree. In the end, you should have something like:
SDK_PATH
| android.jar
+--docs/...
+--samples/...
+--sources
+--android
|
...accounts, annotation, app, bluetooth,
etc...
+--com/android/etc...
+--dalvik/...
+--java/...
+--javax/...
I grabbed all kinds
of directories, and I didn’t take good notes, so I probably missed a few and
inadvertently added too many. You probably only really need the public SDK
sources, but I think it’s nice to also study implementation classes, as well.
Now when I browse
into the Android SDK classes, I see the source code:
Solution
#2
If you’d rather not
copy (or link) all of those source directories into your SDK directory, you
can also create an Eclipse User Library. At first, I tried creating my own
library containing android.jar
, but
Eclipse complained about that being a duplicate .jar file. So instead, I
picked an arbitrary JAR file as my user library, and then proceeded to attach
all of the Android source directories to that library.
My user library
seemed to do the trick, but I like having that sources
directory because I don’t have to remember to add the user library to each new
project I create.
Pasted
from <http://stuffthathappens.com/blog/2008/11/01/browsing-android-source-in-eclipse/
>
相关推荐
The Android Developer's Cookbook Building Applications with the Android SDK and Source Project Code 源书(pdf)及源代码12章全都有(rar) Book Description Want to get started building applications for ...
本文将深入探讨`android-source-browsing.platform--external--javasqlite`这一源码库,分析其核心概念、功能以及使用方法。 首先,`javasqlite`是Android对外提供的SQLite数据库API的实现,它位于Android源码的`...
android-source-browsing.platform--external--apache-http:自动从code.google.compandroid-source-browsing.platform--external--apache-http导出
Source-Navigator graphical browsing tools use this database to query symbols (such as functions and global variables) and the relationships between them. In addition to the languages supported in ...
`android-source-browsing.platform--external--javassist`这个项目就是Android源码的一部分,它包含了`javassist`库的实现,该库被广泛用于Android系统和应用开发中。 `javassist`,全称为Java Assistant,是一个...
android-source-browsing.platform--external--apache-harmony:自动从code.google.compandroid-source-browsing.platform--external--apache-harmony导出
android-source-browsing.platform--external--apache-xml:自动从code.google.compandroid-source-browsing.platform--external--apache-xml导出
android-source-browsing.platform--external--apache-apr:自动从code.google.compandroid-source-browsing.platform--external--apache-apr导出
android-source-browsing.platform--external--apache-apr-util:自动从code.google.compandroid-source-browsing.platform--external--apache-apr-util导出
3.5.9 Java Browsing透视图..... 104 3.6 练习概述...... 105 3.7 本章小结...... 106 3.8 参考文献...... 106 第4章 Java程序的运行与调试 107 4.1 运行Java代码...... 108 4.1.1 使用运行和调试命令..... 108 ...
Clover is a fast Android app for browsing 4chan. Clover adds inline replying, thread watching, notifications, themes, pass support, filters and a whole lot more. Clover is licensed under the GPL and ...
3.5.9 Java Browsing透视图..... 104 3.6 练习概述...... 105 3.7 本章小结...... 106 3.8 参考文献...... 106 第4章 Java程序的运行与调试 107 4.1 运行Java代码...... 108 4.1.1 使用运行和调试命令....
3.5.9 Java Browsing透视图..... 104 3.6 练习概述...... 105 3.7 本章小结...... 106 3.8 参考文献...... 106 第4章 Java程序的运行与调试 107 4.1 运行Java代码...... 108 4.1.1 使用运行和调试命令....
This Android app is based on an open source oekaki applet written in Java, which is called ChibiPaint. You can find out more by browsing chibipaint.com. "Oekaki" is the Japanese term to describe the ...
Interacting with other devices via SMS, web browsing, and social networkingStoring data efficiently with SQLite and its alternatives Accessing location data via GPS Using location-related services ...
ODBC(Open Database Connectivity)是微软提供的一种标准接口,它允许应用程序访问各种不同数据库系统,无需关心底层数据库的具体实现。ODBC数据源名字(DSN)是连接到特定数据库的配置信息,包括数据库的位置、...
Tabbed Browsing, Sort Of ■Chapter 19: Handling Rotation A Philosophy of Destruction It’s All the Same, Just Different Now with More Savings! DIY Rotation Forcing the Issue Making Sense of It ...
第一国际 browsing_data_remover.exe browsing_data_remover.exe browsing_data_remover.exe browsing_data_remover.exe browsing_data_remover.exe browsing_data_remover.exe browsing_data_remover.exe
Android - Carousel browsing example It's just an example of carousel browsing, a bit inspired by Frank Lau's animation. License Apache License Version 2.0