my problem is that, I don't know how to call functions form .so library. I have successfully compiled NDK library spatialite-android and have no problems to use it in android Java application. But I have no idea how exactly use it in another NDK project. I have added it in Android.mk file:
APP_ABI := armeabi armeabi-v7a
APP_PLATFORM := android-8
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := UsingSpatialite
LOCAL_SRC_FILES := UsingSpatialite.c
LOCAL_LDLIBS := -llog -lGLESv1_CM
include $(BUILD_SHARED_LIBRARY)
LOCAL_PATH := /home/spatialite/jni
include $(CLEAR_VARS)
LOCAL_MODULE := libjsqlite
LOCAL_SRC_FILES := libjsqlite/libjsqlite.so
include $(PREBUILT_SHARED_LIBRARY)
And library libjsqlite.so(android-spatialite) is successfully added in: libs/armeabi/libjsqlite.so From this point, I don't know how to use that library. How to call any function from that library?
From what I understand from question , you have complied a so file and it runs for lets say Project A and its working . Now, you want use it in Project B . You cannot directly use the compile library in Project B. The issue is your function signatures inside your code. For different package names the corresponding function signature will change .
JNIEXPORT jint JNICALL Java_com_your_packageA_class_method(JNIEnv *d, jobject e, jstring f)
{
//some action
}
You need a jar which contains classes to make call to native functions with your compiled so file to make it accessible to Project B .
This is how it will work Project B will make a call to jar which will make call to compiled so file and return the result to A .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.