To create your own library, you must
- Create
jni folder in project folder - Create the
libs folder in the project folder Add Adnroid.mk to make the file in the jni folder, it should look like this:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_LDLIBS := -llog LOCAL_MODULE := Test LOCAL_SRC_FILES := Test.cpp include $(BUILD_SHARED_LIBRARY)
Note 1: Test.cpp is the main source file of the library containing the implementation of its own methods. You can add more sources to the list, separated by spaces.
Note 2: Do not include headers, they are included automatically.
Note 3: If you need to enable C ++ STL, create another make file - Application.mk , add it to the jni folder and set the APP_STL := stlport_static flag in it.
Then you will need to create a builder. Refer to this article on how to do this:
After these steps, the creator will create your library in the libs folder, which will be automatically packed in apk when creating the entire application.
Note. Your library name must be lowercase; this is the Linux convention. The prefix "lib" will be automatically added, so the final library name will be libtest.so.
source share