java - android load library failed -
when use system.loadlibrary()
load file, rarely, fails , logcat says
cannot load library: reloc_library[1286]: 121 cannot locate '__cxa_atexit' java.lang.unsatisfiedlinkerror: cannot load library: reloc_library[1285]: 169 cannot locate '__cxa_atexit'... @ java.lang.runtime.loadlibrary(runtime.java:370) @ java.lang.system.loadlibrary(system.java:535)
after searching internet, don't find infomation
cannot locate '__cxa_atexit'
(especially key word __cxa_atexit). why cannot locate function? function seems in libc.so. don't use c++ in native code, c. ndk version android-ndk-r10e. think "cannot locate __cxa_atexit" maybe relative clue.
most of time (maybe billions starts of app), can work well, crashes above. in other words, cannot make crash on testing phones, however, crash on users'.
this problem may same another problem.
update
most of phones crash happens on android 4.0.3 , android 4.0.4. these 2 version both api-15.
update
after reading android's source code, found issue may related dlopen. error message "cannot load library: reloc_library..." comes function dlopen hijacked @ runtime. trace runtime dlopen -> find_library -> init_library -> link_image -> reloc_library.
maybe when resolve symbols in files, finds "__cxa_atexit" undefined. looks in loaded symbols, find nothing. (why cannot find __cxa_atexit ?) runs line 1285, code:
dl_err("%5d cannot locate '%s'...\n", pid, sym_name);
i don't know linker. explain or guess why __cxa_atexit cannot located ? bug of android ?
update
it crashes on android versions, not 4.0.3 & 4.0.4.
error message on 4.0.3 & 4.0.4 is
java.lang.unsatisfiedlinkerror: cannot load library: reloc_library[1286]: 121 cannot locate '__cxa_atexit'
as mentioned above.
when loading other on 4.0.3 & 4.0.4, is
cannot locate 'strcpy'
error message on 4.2.2 is
java.lang.unsatisfiedlinkerror: cannot load library: load_library(linker.cpp:767): can't read file /mnt/asec/app-name-1/lib/libname.so: i/o error
firstly, please make sure called system.loadlibrary() below:
public class mainactivity extends activity { static { system.loadlibrary("main") } ... }
then, according the second answer in post, problem external dependencies loaded statically in native library. hanging on android 4.0 , running fine 4.2 , up.so should check file.
i put answer here:
if have problem, put __android_log_print in jni_onload of library (if have one). if not called, check functions can called statically (beware, might hidden behind macros) , try remove them see if able load library
Comments
Post a Comment