码迷,mamicode.com
首页 > 移动开发 > 详细

[工作积累] Android dynamic library & JNI_OnLoad

时间:2015-01-07 10:44:50      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:

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.

[工作积累] Android dynamic library & JNI_OnLoad

标签:

原文地址:http://www.cnblogs.com/crazii/p/4207642.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!