I'm not actually working on android devices, but I'd like to use the android java std lib for a project of mine. I'm extracting the android java std lib from the android ADT here:
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"
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? I've dug through the sdk download bundle and haven't found anything.
-Haoyi
The Android source tree is located in a Git repository hosted by Google. The Git repository includes metadata for the Android source, including changes to the source and when the changes were made. This page describes how to download the source tree for a specific Android code line.
The JD-GUI is a nice open-source GUI utility to explore Java source code decompiled by the Java decompiler JD-Core. When we see the main window of JD-GUI, we can either open our JAR file by navigating the menu “File -> Open File…” or just drag-and-drop the JAR file in the window.
Jar files are archive files that contains of a lot of different java classes (files). You can use winzip/winrar to open the jar files and you can see those java classes in jar files. Typically you can use a Java decompiler to decompile the class file and look into the source code.
but I'd like to use the android java std lib for a project of mine
I have no idea why you think that would work, any more than trying to use a Windows DLL on Linux.
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?
The source code for Android is at the Android Open Source Project. 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.
In your Android SDK root directory, go to the sources
folder. 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
Unpacking the jar is way more than you need to worry about. Android is open source, so you can get everything you need online. 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. You can also view most (if not all) sources on GrepCode.
If you really want to go through the trouble of extracting the jar and decompiling the source, you can use JD-GUI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With