I am able to build a android shared library using ndk-build only when all my src are in the jni foler, but, I would like to build a shared library using ndk-build without need jni folder, because my project doesn't have java code, so how could I do that?
my simple Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ctest
LOCAL_SRC_FILES := main.cpp
# for logging
LOCAL_LDLIBS += -llog
# for native asset manager
LOCAL_LDLIBS += -landroid
include $(BUILD_SHARED_LIBRARY)
worked as follows:
ndk-build APP_BUILD_SCRIPT=path/to/path/to/project/Android.mk NDK_PROJECT_PATH=path/to/path/to/project
I would still recommend using a subdirectory like jni
for storing the source, to keep the build products in subdirectories such as obj
, libs
and bin
more clearly separated.
But if you have your Android.mk elsewhere, you should be able to do ndk-build APP_BUILD_SCRIPT=path/to/Android.mk
. If you don't want to type this every time, you can add a file named jni/Application.mk
where you type APP_BUILD_SCRIPT=path/to/Android.mk
. Alternatively you have a file named jni/Android.mk
which then includes the real Android.mk
from where you store it.