I'm trying to use a C++ function (that is referenced using a .so file) from my C JNI code. To illustrate my project architecture, it looks like this:
Java -> C (JNI) -> C++ function
This is what my Android.mk file looks like:
LOCAL_PATH := $(call my-dir)
# My C++ library
include $(CLEAR_VARS)
LOCAL_MODULE := my_module
LOCAL_SRC_FILES := ../../../../../../module_service/lib/system/lib/libmodule_service.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
# JNI C code
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
LOCAL_C_INCLUDES += ../../../../../module_service/src
LOCAL_SHARED_LIBRARIES := my_module
include $(BUILD_SHARED_LIBRARY)
Using "ndk-build" command, my project builds. But when I try to run it on my device, it crashes with the following message:
java.lang.UnsatisfiedLinkError: ... nativeLibraryDirectories=[/data/app/com.sampleapp.mysampleapplication-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "liblibmodule_service.so"
What is adding another "lib" to my .so file? If I create another .so file named "liblibmodule_service.so" (in addition to "libmodule_service.so") in my /system/lib directory, it works. But that feels like a hacky solution, and I would prefer to not have both "libmodule_service.so" AND "liblibmodule_service.so" which are the same exact files.
Any help would be greatly appreciated. Thanks!
I guess you may be using System.loadLibrary("libmodule_service");
to load the library, change it to System.loadLibrary("module_service");
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.