Compiling the Kernel

$ cd <project directory root>/kernel/goldfish
$ ARCH=x86 make -j8 goldfish_defconfig
$ ARCH=x86 make -j8



Compiling the Middleware

Total Compilation

There are two types of total compilations.
The first, shall we call it Lazy Compilation, is the one you should preferably do, as it only compiles your recent modifications.
This option basically iterates through all AOSP's jars and recreates the ones that should contain your modified classes.
The second option, Thorough Compilation, is more time consuming, but it also helps you eliminate any doubts regarding whether or not your “bugs” really come from your code, or from conflicts with already compilled files.


Lazy Compilation

This type of compilation should proceed as follows:

1) Start by setting up your environment.

$ cd <project directory root>
$ . build/envsetup.sh
$ lunch 2

The envsetup.sh script will basically provide us a lot of useful commands we'll be using from now on.
For a complete list of commands provided by this script click here.

2) Proceed with the compilation.

$ m

The m command will essentially make sure all jars containing all AOSP's classes get updated.

Thourough Compilation

This type of compilation should proceed as follows:

1) Start by setting up your environment.

$ cd <project directory root>
$ . build/envsetup.sh
$ lunch 2

The envsetup.sh script will basically provide us a lot of useful commands we'll be using from now on.
For a complete list of commands provided by this script click here.

2) Proceed with the compilation.

$ m

The m command will essentially make sure all jars containing all AOSP's classes get updated.


Partial Compilation

Most of the times we are interested in testing only small changes in our code.
Rebuilding the Middleware everytime we want to make those changes would be impractical.
Here are some tips on how to save time:

1) Start by setting up your environment.

$ cd <project directory root>
$ . build/envsetup.sh
$ lunch 2

The envsetup.sh script will basically provide us a lot of useful commands we'll be using for now on.
For a complete list of commands provided by this script click here.

2) Compile your modified files

There are four commands you can use to compile your modified files.
Here we illustrate how to use all of them.
As an example we assume we made a change in the android.os.AsyncTask class and want to compile it.
The complete path to this file is: <project directory root>/frameworks/base/core/java/android/os/AsyncTask.java

2a) Compile your modified files from their path
$ cd <project directory root>/frameworks/base/core/java/android/os/
$ mm

The mm command will essentially compile every file from this directory.

2b) Compile your modified files from their path and their corresponding dependencies as well
$ cd <project directory root>/frameworks/base/core/java/android/os/
$ mma

The mma command will compile every file from this directory as well as their dependencies.

2c) Compile your modified files
$ mmm <project directory root>/frameworks/base/core/java/android/os/

The mmm command will essentially compile every file from the provided directory.

2b) Compile your modified files and their corresponding dependencies as well
$ mmma <project directory root>/frameworks/base/core/java/android/os/

The mmma command will compile every file from the provided directory as well as their dependencies.


Useful links

https://udinic.wordpress.com/2014/07/24/aosp-part-3-developing-efficiently/