What is the easiest working example of importing an NDK module for Android?

I can not find a working example of the NDK function for Android NAD. The following Android.mk files seem to be correct, and the internal module builds and executes without errors. However, when the plug-in fails, the following error messages appear:

Android NDK: jni / internal / Android.mk: internal: LOCAL_MODULE_FILENAME should not include file extensions
Android NDK: jni / internal / Android.mk: internal: LOCAL_MODULE_FILENAME should not contain file extension
/ home / caleb / dev / android-ndk-r8e /build/core/build-shared-library.mk:30: * Android NDK: Cancel. Stop.

Internal containing Android.mk file:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := inner
LOCAL_MODULE_FILENAME := libinner
LOCAL_SRC_FILES := inner-module.c

include $(BUILD_SHARED_LIBRARY)

External containing Android.mk file:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := outer

$(call import-module,inner)

LOCAL_SHARED_LIBRARIES += inner

include $(BUILD_SHARED_LIBRARY)
+1
2

import-module . , "", NDK .

+4

, , .

, Android.mk:

# save away the previous local path
INNER_SAVED_LOCAL_PATH := $(LOCAL_PATH)

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := inner
LOCAL_MODULE_FILENAME := libinner
LOCAL_SRC_FILES := inner-module.c

include $(BUILD_SHARED_LIBRARY)
# at this point LOCAL_MODULE_FILENAME will have been auto
#  set to libinner.so or similar by the call to BUILD_SHARED_LIBRARY

# restore previous local path
LOCAL_PATH := $(INNER_SAVED_LOCAL_PATH)

, Android.mk:

LOCAL_PATH := $(call my-dir)

$(call import-module,inner)
# at this point
#  a) we've still got the correct LOCAL_PATH as we didn't trash it in
#     the included Android.mk file
#  b) LOCAL_MODULE_FILENAME is still set to libinner.so which if not
#     unset will cause BUILD_SHARED_LIBRARY to complain

include $(CLEAR_VARS)
# we've now got a clean slate

LOCAL_MODULE := outer

# the build system has 'remembered' the inner module
LOCAL_SHARED_LIBRARIES += inner

include $(BUILD_SHARED_LIBRARY)

, , :)

+2

All Articles