I am trying to build my own libs and apps in external directory of the AOSP, but the problem is i have to run make each time and the make will compile/build whole the android. In my external apps folder i have Android.mk file, but i cannot build it using ndk-build, it will look for JNI folder and NDK_BUILD_PATH, so the question is:
How can i build it without rebuilding whole AOSP?
To download and build the AOSP project you should have a 64-bit version of either Linux (18.04 or greater) or Mac OS installed. Here, RAM plays a very crucial role when it comes to building / compiling the android source code. According to the official docs, it is recommended that you should have at least 16GB of RAM.
As of June 2021, Google is using 72-core machines with 64 GB of RAM internally, which take about 40 minutes for a full build (and just a few minutes for incremental builds, depending on exactly which files were modified).
With WSL 2, it's rather easy for Windows users to compile AOSP or custom ROMs like LineageOS from scratch without installing a full-fledged GNU/Linux distribution.
A plain make
invocation will not rebuild more than necessary, but even with a leaf library or binary even an incremental build can take a few minutes. If you only want to build your particular module you can look at the functions briefly documented at the top of build/envsetup.sh. Specifically, the m
and mm
shell functions should be useful as they only build one or more modules without caring about their dependencies and without even trying to read all Android.mk files found in the tree. Using them should speed up incremental builds significantly (but all dependencies must have been built at some point, i.e. they're only useful for incremental builds).
build/envsetup.sh also defines a number of other shell functions that are useful for building the Android platform and working with its source code.
You can get list of all of the modules in your Android code with the following command:
make modules
To build any single module:
make [modulename]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With