Building the complete android.jar from the android source

4,282 views
Skip to first unread message

andro_learner

unread,
Sep 13, 2012, 2:17:41 AM9/13/12
to Android Building
Hi,
As far as i can understand the android.jar in the android sdk contains
only stubs which throws runtime exception.Is there a way I can compile
the android source to get the complete android.jar with full
implementation.


Regards

Ying Wang

unread,
Sep 21, 2012, 1:47:21 PM9/21/12
to android-...@googlegroups.com
No the build system does not have such functionality.


--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

Ying Wang

unread,
Sep 21, 2012, 6:02:28 PM9/21/12
to android-...@googlegroups.com
The nobrainer answer is to rebuild the SDK with "make -j showcommands dist PRODUCT-sdk-sdk", and you'll find android.jar in the output zip file.
The fastest way to build android.jar only:
$ lunch full-eng && make -j showcommands out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/javalib.jar
That file is actually the one to be android.jar inside the sdk package.

On Fri, Sep 21, 2012 at 11:54 AM, Jin <jian...@gmail.com> wrote:
Hi Ying,

Thanks for reply. I know you are an expert in Android compiling. I have one confusion: if I want to modify ActivityManager.java(which is in Android.jar) and rebuild to have a new android.jar, I should compile
1. The whole Android source code(several GB)
2. A certain branch of the whole Android source code.
3. Just a few .jars related to android.jar
Please help

在 2012年9月21日星期五UTC-4下午1时47分28秒,Ying Wang写道:

Ying Wang

unread,
Sep 24, 2012, 12:30:51 PM9/24/12
to android-...@googlegroups.com
You should not change anything in the out directory: the intermediate dir will be nuked when it reruns the rule.

On Sun, Sep 23, 2012 at 3:32 PM, Jin <jian...@gmail.com> wrote:
Hi Ying,

Thanks for all your guidance. I have finally built Android Source and SDK. But I am still not sure how to build self-modified android.jar(javalib.jar) in the fast way as you indicated.
Here is what I did: I made small modification to the ActivityManager.java which is located at out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/android/app, that is, I added annotation in it and change existing " throw new RuntimeException("Stub!") " to " throw new RuntimeException("Stubmodified!") ". Then I used the command
$ lunch full-eng && make -j showcommands out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/javalib.jar
to build a new javalib.jar. After that, I just unzip the new javalib.jar to .class files, and consequently decompile .class files to .java files. However, I did not find my changes in ActivityManager.java.

I wonder if I did something wrong or my method itself is totally wrong. Then, how to make modification to android.jar/Android framework, and apply the new one on emulator/devices?

Thanks for having your time

Ying Wang

unread,
Sep 26, 2012, 12:21:17 PM9/26/12
to android-...@googlegroups.com
You can't change the implementation of android.jar: they are just API stubs generated by the java doc tools.

On Tue, Sep 25, 2012 at 8:37 PM, Jin <jian...@gmail.com> wrote:
Hi Ying
Actually, I found it is absurd to change files under out directory after I submitted last post. But I am not sure where is the source code corresponds to out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/javalib.jar. Then I briefly searched the whole Android Source, and found /frameworks/base/core directory likely to be the source code for building. So I modified the ActivityManager.java under /frameworks/base/core/java/android.app/. However, after building using $ lunch full-eng && make -j showcommands out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/javalib.jar, I did not find my modification in the new javalib.jar. 

I wonder if I found the wrong source directory or anything else?
Thanks very much

在 2012年9月24日星期一UTC-4下午12时30分59秒,Ying Wang写道:
Reply all
Reply to author
Forward
Message has been deleted
0 new messages