Android OS Source Code Modification (Part-II): Making the System

Considering that you have followed all the instructions in my previous post here, I take this series of post forward which illustrates how to compile the source code in order to get it running in an emulator.

Building Android 2.2 source to run an Emulator

The main reason for first doing this instead of illustrating the modification of source is that, you should know what steps you have to perform in order to see the changes that you have made.
Secondly, you must be aware of outcomes of your modification.
Third, You must know what your objective is, then you'll be able to work more precisely, for example, you now know that you have to run your modifications in an emulator, so you'll see the screens, change them, make the build and will again run the emulator to see the changes.
Moreover, I feel that it will help you understand what actually happens when we build for a system, as a result, you'll be able to make changes more comfortably, and without working vaguely .

So, I have just ended up creating an emulator, and there's really nothing big involved in this.

To start the compiling/building/making process, we just use the make command.
And to make it deliver an emulator, we use the sdk switch with make command.
This is done in the following manner:

In a shell prompt, first go to the directory where your files are (probably under 'bin' or 'mydroid') or you can also set the $PATH to have any of these folders in your path, then run:

$ make sdk

The above lines will compile the source and will generate an sdk folder under your root directory (most probably this root directory will be 'bin')
If your build fails due to a missing run-java-tool then run the following command to simple set your environment variable ANDROID_JAVA_HOME:

$ export ANDROID_JAVA_HOME=$JAVA_HOME

Then again start the build process with the make sdk

Now wait for a long time, as it is going to take long for it to compile the code.
on my machine, it took 5 hours.

When it finishes, you should be able to find one sdk folder under following directories:

~/bin/out/host/[OS build]/sdk

in my case, the [OS build] folder was linux-x86, so just replace it with yours.
under normal circumstances, it should be yours too.

This folder will have the emulator which you can run.
This emulator can be found in:

~/bin/out/host/[OS build]/sdk/[sdk version dependant folder]/tools 

here [OS build] was linux-x86 on my system
and [sdk version dependant folder] was android-sdk_eng.root_linux-x86.

To run the emulator that you have just built, you'll run the emulator command from a terminal, but before that, you must have an AVD to run the emulator.

So,to create an AVD, run the following commands under a terminal

$ cd /bin/out/host/[OS build]/sdk/[sdk version dependant folder]/tools
$ ./android create avd -n [Your AVD's name] -t 1 

here [Your AVD's name] is whatever you want your AVD to be named like

As a result, you might get something like this-

Android AOSP (Preview) is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Created AVD '[Your AVD's name]' based on Android AOSP (Preview),
with the following hardware config:
hw.lcd.density=160

Now, to run the emulator with this AVD, run the following command:


~/bin/out/host/linux-x86/sdk/android-sdk_eng.root_linux-x86/tools$ ./emulator @[Your AVD's name]

You should get your Emulator running.

In the next post, I might show how to make changes in few things of the source, and how to build an emulator to see those changes.

Enjoy!

1 comments:

vineeta singh said...

can you please post ...how to modify source code and run on emulator to see those changes