I have precompiled shared library (.so), named libxxx.so.3.3. I don't know why the name after compilation was "libxxx.so.3.3". I'd like to use it in my Android app via JNI. For this i've created ndk module xxx_jni:
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := xxx
LOCAL_SRC_FILES := xxx.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := xxx_jni
LOCAL_SRC_FILES := xxx_wrapper.c
LOCAL_SHARED_LIBRARIES := xxx
LOCAL_C_INCLUDES := /softdev/xxx/host/include/
include $(BUILD_SHARED_LIBRARY)
I had to rename ".so.3.3" to ".so" as ndk-build failed to compile libxxx_jni.so:
Android NDK: ERROR:/Users/user/Documents/dev/src/xxx_jni/jni/Android.xxx: LOCAL_SRC_FILES should point to a file ending with ".so"
Android NDK: The following file is unsupported: libxxx.so.3.3
My wrapper class (for JNI):
#include "xxx_wrapper.h"
#include // include "xxx" library header
#ifndef _Included_name_antonsmirnov_android_xxx_wrapper
#define _Included_name_antonsmirnov_android_xxx_wrapper
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: name_antonsmirnov_android_xxx_wrapper
* Method: exec_test
* Signature: (Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_name_antonsmirnov_android_xxx_1wrapper_exec_1test(JNIEnv *, jobject, jstring)
{
// using method from "xxx" library
xxx_method();
return 7;
}
So after ndk compilation (ndk-build) i have 2 stripped files in "libs/armeabi" folder: libxxx.so and libxxx_jni.so.
Then i try to load libraries in runtime in wrapper class:
public class xxx_wrapper {
static {
System.loadLibrary("xxx");
System.loadLibrary("xxx_jni"); // error here!
}
error:
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]: 167 could not load needed library 'libxxx.so.3.3' for 'libxxx_jni.so' (load_library[1093]: Library 'libxxx.so.3.3' not found)
So i'm in stuck what i've missed.. I've tried to leave ".so.3.3" extension and symlink ".so" -> ".so.3.3" but the same result. As far as i understand the problem is that xxx_wrapper lib still wants ".so.3.3" library loaded, but it's ".so".