Detailed example of android.mk template developed by Android
Detailed example of android.mk template developed by Android
There are a lot of articles about Android NDK development. My blog also shares a lot of experience and skills related to NDK development. Today, I simply wrote an example template of android.mk for beginners' reference.
This template mainly gives you examples of the following problems in Android NDK development:
1. How to automatically add the list of source files to be compiled 2. How to add the dependencies of third-party static libraries and dynamic libraries 3. How to construct a complete NDK engineering framework
Suppose our project relies on libmath. A, libjson. A and libffmpeg.so. The project includes the following modules: algorithm, core, network, utils and tests. Each module has several. C /. H files. We need to compile the whole project into a dynamic library and use native_ The functions in SDK. C provide a call interface to the Java layer.
Then, we can divide the JNI directory of Android project as follows:
The writing method of the corresponding android.mk file is as follows (Note: the project file can be viewed online in my GitHub (@ jhuster / Android) or downloaded in the attachment at the end of this blog):
For android.mk, if you want to rely on third-party library files, you must add prebuild_ XXXX_ Precompiled by library, local_ SRC_ The files macro gives the list of source files to be compiled. Here, I automatically scan the source files in the specified directory through the subst and wildcard functions. Finally, I use build_ Executable compiles an executable program that can run on the ADB shell command line for unit testing of code.
If you have any questions, please leave a message or go to the community of this site for exchange and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!