简体   繁体   English

如何获取android.jar的源代码

[英]How to get source code for android.jar

I'm not actually working on android devices, but I'd like to use the android java std lib for a project of mine. 我实际上并不是在研究android设备,但是我想将android java std lib用于我的项目。 I'm extracting the android java std lib from the android ADT here: 我在这里从android ADT中提取android java std lib:

http://developer.android.com/sdk/index.html http://developer.android.com/sdk/index.html

After unzipping the bundle, it's in 解压缩捆绑后,它就在

adt-bundle-windows-x86_64-20130729\sdk\platforms\android-18\android.jar

However, when I open this up in Intellij, it doesn't show any source code: all methods are just labelled as "compiled code" 但是,当我在Intellij中打开它时,它没有显示任何源代码:所有方法都只标记为“编译代码”

Is there any way to get the source code (in a jar or otherwise) for the android.jar so I can hook it up to the IDE so I can nicely browse the source code of the standard library? 有没有办法获得android.jar的源代码(在jar或其他方面),所以我可以将它连接到IDE,这样我就可以很好地浏览标准库的源代码了? I've dug through the sdk download bundle and haven't found anything. 我已经挖了sdk下载包,但没有找到任何东西。

-Haoyi -Haoyi

but I'd like to use the android java std lib for a project of mine 但我想将android java std lib用于我的项目

I have no idea why you think that would work, any more than trying to use a Windows DLL on Linux. 我不知道为什么你认为这样可行,不仅仅是试图在Linux上使用Windows DLL。

Is there any way to get the source code (in a jar or otherwise) for the android.jar so I can hook it up to the IDE so I can nicely browse the source code of the standard library? 有没有办法获得android.jar的源代码(在jar或其他方面),所以我可以将它连接到IDE,这样我就可以很好地浏览标准库的源代码了?

The source code for Android is at the Android Open Source Project . Android的源代码位于Android开源项目中 The source code for the android.jar is mostly in the platform_frameworks_base repo ( GitHub mirror ), but the JAR is really an output of a firmware build. android.jar的源代码主要在platform_frameworks_base repo( GitHub镜像 )中,但JAR实际上是固件构建的输出。

In your Android SDK root directory, go to the sources folder. 在Android SDK根目录中,转到sources文件夹。 Here you will find the source files for the different platforms you have downloaded. 您可以在此处找到已下载的不同平台的源文件。

Note: This gives you the Java code for Android libraries such as Activity 注意:这为您提供了Android库的Java代码,例如Activity

Unpacking the jar is way more than you need to worry about. 打开jar包装的方式远比你需要担心的要多。 Android is open source , so you can get everything you need online. Android是开源的 ,因此您可以在线获得所需的一切。 To start, you can browse most of the source on Android's GitHub account , or download the source tree on the Android Open Source Project website . 首先,您可以在Android的GitHub帐户上浏览大部分来源,或者在Android开源项目网站上下载源代码树。 You can also view most (if not all) sources on GrepCode . 您还可以在GrepCode上查看大多数(如果不是全部)源。

If you really want to go through the trouble of extracting the jar and decompiling the source, you can use JD-GUI . 如果你真的想解决提取jar和反编译源代码的麻烦,你可以使用JD-GUI

As you use eclipse, use 当你使用eclipse时,请使用

jadclipse jadclipse

which extrach any jar that in eclipse, u can view any source code with out download and also without internet. 在eclipse中,你可以查看任何jar,你可以查看任何源代码,无需下载,也可以没有互联网。 It has also export source code, As a developer It help u most times. 它还有导出源代码,作为开发人员它帮助你大多数时间。 :-> link to download : - > 链接下载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM