Where should Android.mk be?

The documentation for Android NDK contains the following instructions:

The Android.mk file is located in a subdirectory of your jni / directory [...] http://developer.android.com/ndk/guides/android_mk.html

I can interpret from this that the Android.mk file should be placed in [project_path]/jni/[module_name]/Android.mk , and each module has its own specific Android.mk file, as this distinguishes it from the widely used application Application.mk , but when I execute ndk-build following error message appears:

Android NDK: Android.mk does not exist. / jni
Android NDK: If intentional, define APP_BUILD_SCRIPT to indicate
Android NDK: for a valid build of an NDK script.

From this, I have to create one Android.mk file next to my Application.mk file or define APP_BUILD_SCRIPT in Application.mk to point to a single Android.mk file. This contradicts the documentation and does not allow me to wonder why there is a need for several makefiles when Android.mk contains definitions for all modules in any case, which can also be placed in Application.mk .

Looking at a few examples of NDK projects, I found that the Android.mk file is in the same directory as Application.mk , and running ndk-build on them seems to work.

What is missing?

+9
android android-ndk makefile
source share
1 answer

I can answer at least some of your questions. You are right that the documentation is a bit confusing. If you use one native module, indeed Application.mk may seem redundant - but there are a few things that only Application.mk can install (you can see here: Application.mk ). Application.mk is for settings that apply to all modules, while Android.mk is for certain module parameters. Indeed, usually simple projects have one Android.mk and are in the same folder as Application.mk.

You can determine where to put them, it also depends on how you create your code - for example, if you use a task to build ndk using the "ndk-build" command and commandLine, you pass the folder path as an argument. Usually In my experience, they are under the jni folder.

0
source share

All Articles