Android NDK, use functions from a compiled .so library in another Android NDK project

My problem is that I do not know how to call a function. form.so library. I have successfully compiled the NDK spatially android library and have no problem using it in a Java application for Android. But I have no idea how to use it in another NDK project. I added it to the 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 the libjsqlite.so library (android-spacesite) has been successfully added to: libs / armeabi / libjsqlite.so From now on I don't know how to use this library. How to call any function from this library?

+4
source share
1 answer

From what I understand from the question, you have executed such a file, and it is launched in order to say that Project A and its work. Now you want to use it in Project B. You cannot directly use the compilation library in Project B. The problem is your signature function inside your code. For different package names, the corresponding function signature will be changed.

 JNIEXPORT jint JNICALL Java_com_your_packageA_class_method(JNIEnv *d, jobject e, jstring f) { //some action } 

You need a jar that contains classes for calling your own functions with your compiled such file to make it accessible to Project B.

Here's how it will work. Project B will make a jar call, which will call the compiled file and return the result in A.

0
source

Source: https://habr.com/ru/post/1444548/


All Articles