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)
I would still recommend using a subdirectory like
jni
for storing the source, to keep the build products in subdirectories such asobj
,libs
andbin
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 namedjni/Application.mk
where you typeAPP_BUILD_SCRIPT=path/to/Android.mk
. Alternatively you have a file namedjni/Android.mk
which then includes the realAndroid.mk
from where you store it.worked as follows: