[工作积累] Android dynamic library & JNI_OnLoad

Bionic libc doesn‘t load dependencies for current .so file (diff from Windows or Linux)

so a explicit calling of Java‘s System.loadLibrary() is needed, in order to load depedency libraries. otherwise the original .so will fail to load.

 

JNI_OnLoad will be called mostly on  System.LoadLibrary() or equavilent calls

System.loadLibrary("gnustl_shared");

 

the .so file is loaded & and symbol get loaded by common dynamic library function:

dlopen

dlsym

 

if the symbol "JNI_OnLoad" is not found in the lib, dalvik will simply do nothing, but a Debug Log: No JNI_OnLoad found in xxx.so, skipping init.

 

details at:

 dalvik/vm/Native.c

 

NatvieAcitviy: JNI_OnLoad is not get called

For the startup library speicified by "android.app.lib_name", JNI_OnLoad is not get called,

only libs loaded by System.loadLibrary() will.

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。