如何轻松找到Android类的源代码
我知道我可以从 https://android.googlesource.com 访问 android 源代码,但很难选择如果我只知道包和 android 类的名称,则正确的 git 存储库。
没有办法在 https://android.googlesource.com 中查找文件吗?
I know I can access android source code from https://android.googlesource.com, but it's hard to select the right git repo if I only know the package and the name of an android class.
Isn't there a way to locate a file in https://android.googlesource.com?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
在我看来,今天查看 android 源代码的最佳方式是 github 存储库:
https://github.com/android/< /a>
公共 java 类可以在这里找到 https://github.com /android/platform_frameworks_base/tree/master/core/java/android
内部包在这里https://github.com/android/platform_frameworks_base/tree/master/core/java/com/android/internal
资源在这里 https://github.com/android/platform_frameworks_base/tree/master/core/res/res
支持库https://github.com/android/platform_frameworks_support
In my opinion today the best way to look into android sources is the github repository :
https://github.com/android/
Public java classes can be found here https://github.com/android/platform_frameworks_base/tree/master/core/java/android
Internal package is here https://github.com/android/platform_frameworks_base/tree/master/core/java/com/android/internal
Resources are here https://github.com/android/platform_frameworks_base/tree/master/core/res/res
Support library https://github.com/android/platform_frameworks_support
自 2011 年起,可以使用 SDK 管理器下载源代码(窗口 > Android SDK 管理器)
编辑: Eclipse 似乎会定期扫描外部文件夹以获取更新。如果这让您烦恼,您可以将该文件夹压缩到 .jar 中,然后告诉 Eclipse 在该 jar 中查找源代码。然后 Eclipse 将不再扫描更改。
Since 2011 the source code can be downloaded with the SDK Manager (Window > Android SDK Manager)
Edit: Eclipse seems to regularly scan the external folder for updates. If this annoys you, you can zip the folder into a .jar and then tell Eclipse to look in that jar for the sources. Eclipse will then no longer scan for changes.
对于单个 针对 Android 项目提出的问题 code>.jar 包含 Java 源代码的文件。
该问题已被拒绝,但评论是在 Eclipse 中访问源代码的良好方法来源。
There is an issue raised against Android project for a single
.jar
file containing the Java sources.The issue has been declined but the comments are a good source of methods to access the source in Eclipse.
另外,这是一个关于如何获取源代码的非常好的教程在 Eclipse 中,无需搞乱任何存储库或其他任何内容,它包含源代码的 zip 文件(可能已过时)
also, this is a very good tutorial on how to get the source in eclipse, without having to mess with any of the repos or anything, it includes zip files of the the source (which might be out of date)
您可以通过 https://cs.android.com 轻松搜索任何 Android 类。
You can search for any Android class through https://cs.android.com easily.
您想要查看的大多数内容都可以在
frameworks/base
仓库。这几乎包括构成 Android Java 框架的所有公共和私有 API 类。
如果您希望能够从 Eclipse 中浏览源代码,可以遵循以下指南:http://blog.michael-forster.de/2008/12/view-android-source-code-in-eclipse.html
最后,Android SDK 参考搜索扩展可让您通过以下方式浏览公共 API:在 URL 栏中输入
ad
,它会向每个 Javadoc 页面添加一个方便的“查看源代码”链接。Most things you'll want to see can be found under the
frameworks/base
repo.This includes pretty much all the public and private API classes that make up the Android Java framework.
If you want to be able to browse the source from within Eclipse, you can follow this guide: http://blog.michael-forster.de/2008/12/view-android-source-code-in-eclipse.html
Finally, the Android SDK Reference Search extension for Chrome lets you browse the public API by typing
ad
into the URL bar, and it adds a convenient "view source" link to each Javadoc page.