Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a part of Android AOSP?

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?

like image 298
Andrei Golubev Avatar asked Jan 04 '14 17:01

Andrei Golubev


People also ask

How do you make an 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.

How long does it take to build AOSP?

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).

Can I build AOSP on Windows?

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.


2 Answers

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.

like image 59
Magnus Bäck Avatar answered Sep 16 '22 13:09

Magnus Bäck


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]
like image 38
Shridutt Kothari Avatar answered Sep 16 '22 13:09

Shridutt Kothari