Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I partially build Android source code?

Tags:

android

I have been modifying Dalvik VM and I was wondering if there is a way that I can build only Dalvik VM from android source code.

If I can build Dalvik VM separately then how can I add the modified Dalvik VM to Android system?

like image 972
codereviewanskquestions Avatar asked Nov 23 '11 07:11

codereviewanskquestions


1 Answers

Once you have done the initial build (I am assuming you have followed the steps described here: http://source.android.com/source/building.html), you can build just the Dalvik VM by doing

$ make libdvm

When the build is done, you will see some output near that looks something like

Install: out/target/product/generic/system/lib/libdvm.so

This is the newly built Dalvik VM (or more specifically, the library in which the Dalvik VM is implemented). The last part of the out path is where the installed file is expected, in this case /system/lib/libdvm.so. To install your new VM, first ensure you are root and then remount the system partition

$ adb root
adbd is already running as root
$ adb remount
remount succeeded

you can now push the new VM to the system:

$ adb push out/target/product/generic/system/lib/libdvm.so /system/lib/libdvm.so

Note that if you run the emulator, this change is not permanent, since the emulator reloads system.img each time it starts. On a device however, the change will be permanent. Also, since Android preloads a process called Zygote that is later used to fork application processes, you need to reboot the system to make the new VM be used in applications

$ adb reboot

You can actually rebuild virtually all Android components this way. The general steps are

  1. Find Android.mk in the source tree for the component you wish to rebuild
  2. Find the module name. In the case of the Dalvik VM, the line looks like this: LOCAL_MODULE := libdvm
  3. make the module name, which is libdvm for Dalvik VM
  4. The built file will be announced in the build output and start with Install:. In the case of the Dalvik VM, this is Install: out/target/product/generic/system/lib/libdvm.so
  5. adb root and adb remount, then adb push the built file to a running Android system. The destination path is the last part of the out file path, which in the case of dalvik is /system/lib/libdvm.so
like image 98
Martin Nordholts Avatar answered Oct 20 '22 23:10

Martin Nordholts