Recently the company framework has just been transplanted, because the framework program to call subroutines, each subroutine is a so file, there are hundreds of, all so and apk packaging unrealistic, timely upgrade maintenance is also very troublesome. So you need to put the SD card. Consider two different ways
1
The/data/app-lib/package name/so file that is placed on the device (and a default path is not remembered) is copied to this path when the program is initialized, and LoadLibrary is loaded from the two default paths.
This way the device needs to be rooted, less efficient, and if the application is unloaded all so is gone.
2
directly into the SD card via Dlopen open the SD card so then Dlsym Find the function address
#include "dlfcn.h"//dlopen header file Void (*pf_threadcannback) ();//Declaration function pointer type void (*PF_PROGRAM) (); void *handle;bool GetMethod () {handle = Dlopen ("//storage//emulated//0//lib//libprogram.so", rtld_now);//Dlopen ("/ Storage/emulated/0/lib/libtwolib-second.so ", Rtld_now); if (!handle) {__android_log_print (ANDROID_LOG_INFO," JNIMSG "," Your params is null:%s ", Dlerror ());} else {__android_log_print (android_log_info, "jnimsg", "Your params is GOOD2");} Pf_program = Dlsym (handle, "<span style=" Color:rgb (Wuyi, Wuyi, Wuyi); font-family:arial; font-size:14px; line-height:26px ;" >myFunc</span> "); Point to the function name you want to call in so Pf_threadcannback = Dlsym (handle, "Threadcallback"), if (Dlerror ()) {__android_log_print (android_ Log_info, "Jnimsg", "Dlsym no Error"); return false;} return true;//Call//Dlclose (handle) When releasing resource recommendation program exit;}
The function address is found and then executed directly.
For example, to invoke the MyFunc () function in so to execute Pf_program () is OK.
Demo Address
Android NDK loaded on SD card so