Http://www.eoeandroid.com/thread-55467-1-1.html
First of all, you need to determine whether your. so is supported by android, not all. so can be, itself is divided into linux-X86 and linux-arm two categories. Check whether so is compiled into so in ARM mode.
$ File libtest. so
Libtest. so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped. PS ndk-build generated. so is certainly supported.
Http://kaneiqi.iteye.com/blog/666816
Http://blog.csdn.net/victoryckl/article/details/6832333
Http://blog.csdn.net/vrix/archive/2010/03/06/5351196.aspx
There is an so file named "libold. so ". The method "int oldmethod ()" is provided ()".
Now, for some reason, the interface changes, or you do not know old. so interface, but the oldmethod method is used. Therefore, use a new interface. If the interface is "jint Java_com_example_newmethod (JNIEnv *, jobject )"
Generate a new so file for use.
The mynewlib. c file is as follows:
# Include <string. h>
# Include <jni. h>
# Include <dlfcn. h>
Jint
Java_com_example_tnewmethod (jnienv * ENV, jobject thiz)
{
Void * filehandle = dlopen ("/data/COM. Example/lib/libold. So", rtld_lazy); // open the original so file
If (filehandle)
{
INT (* oldmethod )();
Oldmethod = dlsym (filehandle, "oldmethod"); // introduce the function in the original so
If (oldmethod)
{
// Call this function
}
}
}
Here, dlopen and dlsym are functions in libdl. so under/system/lib in android. Therefore, you need to export this file from android and directly use pull in the simulator. If so is not linked during compilation, compilation fails. With this file, Android. mk is as follows:
LOCAL_PATH: = $ (call my-dir)
LOCAL_MODULE: = my-new-lib
LOCAL_SRC_FILES: = mynewlib. c
# Here, libdl. so is linked. It seems to be placed in the ANDROID_NDK_ROOT path. If not, you can find the correct path based on the Compilation error information.
LOCAL_LDLIBS: =-L.-ldl
Include $ (BUILD_SHARED_LIBRARY)