简体   繁体   中英

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?

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, ie 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]

To briefly address the more general case, mm is a useful command, but the location from which it should be run is not well documented - or more specifically, it is not always clear what is a "module".

Let's say you have made a change to SystemUI, which is a specialized app that is key to the overall functionality of Android. This is part of the frameworks/base repository.

If you just go to the frameworks/base directory, and execute mm it will not find anything to do - your changes will be ignored.

To actually pick up your changes with mm you have to be in the directory where they reside - in this example, you would need to be in frameworks/base/packages/SystemUI. The appropriate location for other codebases will be different - but as a guess , you probably need to be where the Android.mk covering your changes resides.

You can then either use the make snod target from the top of the tree to rebuild the system.img and flash it with fastboot, or use adb remount , adb push the new SystemUI.apk, and then adb shell "start; stop" to restart the Android framework.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM