[Sony Ericsson XPERIA X10 Mini] slade87:
Building Android from Source

Now lets get started with the more advanced part and the most frustrating part in the beginning. The easiest way to build for the mimmi would be to sync the Cyanogen Gingerbread source code. Which can be checked out using the repo binary (see tutorials on googles website also which packages for which architecture (x86 or x64) are addionally needed also the correct java version is important)

Now lets cut to the chase.

repo sync -u http://github.com/CyanogenMod/... -b gingerbread (or froyo or another branch you would like to check out)

once your repo is synced (you could also add "-j8" to enhance the speed of the repo command, it will take quite a while) you are almost ready to start. If you synced an AOSP source you will have the get your device and hardware libraries ready first. This means you will have to port i.e. the device project and hardware project (mimmi and msm7227-common folders from CM and also hardware folder from CM) to the AOSP source. It makes sense to port these to your AOSP source since they are the most complete so far. For Camera libraries you can sync from doixanhs repo the libcamera-5mp.

Now lets get a short overview over the Android source, it contains of various folders:

frameworks

device

vendor

hardware

platform

external

These are the most interesting, frameworks folder holds a bunch of android libraries and files which provide the functionality however often you will need to change a few things here and there since the mimmi is unique in its hardware. Everything you change will need to be approved with the following command:

make update-api

This will add all the functions, variables or anything else to the current-api.xml and ensure its available at build time.

The device folder holds device specific files, build-configs and so on. Lets look at some of the important files:

device/semc/mimmi/overlay/frameworks/base/res/res/values/config.xml/power.xml

The two xmls hold configurations of the build process which are device specific either LightSensorWarmupTime and so on the full list is in the root folder of frameworks/base/res/res/values/config.xml <-- any part you feel you need to change copy the lines from there and change in you device specific config.xml.

Now to another file:

device/semc/msm7227-common/BoardConfig.mk

This files olds the device sepecific configurations for the ARM, WLAN, etc.

Look at all the files in mimmi and msm7227-common and figure out what they do, google of course will guide you on that.

Also take a look in the:

vendor/cyanogen/products/

folder and find the mimmi config and get familiar with this as well. Nobody will be able to help unless you face specific issues. Developing is learning by doing and a lot of self teaching and the will to understand all of this yourself. We can't teach but you can learn. Specific questions however are usually proudly answered by most devs if they have already figured it out.

Lets start building now, first you'll need to get your lunch command to know which devices have makefiles (I always do it to be sure)

source build/envsetup.sh

This will now add all the known devices to your lunchcombo (the devices are usually definied in the vendorsetup.sh pointing to the makefiles)

lunch

Will get you the list of available devices and will wait for user input to select the device you want to build, choose the mimmi.

make -j4

This will start the building process with 4 jobs.

Now its time to get a coffee. Usually you will have a bunch of different issues on this part but the CM source is pretty good and you might be lucky there.

Now lets look at typicial errors:

symbol not found : means a variable in used in the code has not been defined, before its use this one is a tricky one
try to locate the source file and find the line the compiler is complaining about. Now check in the framework usually in
res/res/values or layout look for the type of the erros (String or array) and look in the corresponding xml if the variable
is present. Now look in vendor/cyanogen/overlay if your variable is also declared there and so on.

function not found/function of incompatible types : also a tricky one, you might sync a repo and made local changes to
a file and suddenly your functions another file calls are not present or have changed, find the differences between them and
think about how it has changed, maybe add the function again or maybe another function does the job now. you will need
to locate the changes compare them and you should be fine again

No Rule to make target: this one is usually due to a missing/incomplete Makefile you might need to add manually or
if you don't need it anyway the easiest would be to delete the not building folder

Once your source has finished compiling you will find you system image in:

out/products/mimmi/system/

As of now unfortunately its still missing a few files here and there. Compare ROMs and Compare what might needs to be added. However I advise not switch libraries around its best to use your own libraries. However sometimes you will face issues when doing this so start with the files created there and just add the recovery and ramdisk to your rom. Now observe via adb if everything is running. This will take time and add one missing lib after another one and reboot, after each (like grallocs or librils or fm libs and so). This is basically a debugging part of the job.

You will now add one by one more functionality, but keep in mind to use logcat to see what goes wrong, maybe some stuff can be changed in the source rather then randomly adding stuff.