NOTE: I'm not an Android developer.
That said, I found this StackOverflow question, which mentions similar behavior to what you described:
The master Android process is zygote
. Its like init
in Linux. Zygote
loads OpenSSL when its start, and it loads version 0.9.8. If you link
against OpenSSL 1.0.1, then you will get mysterious runtime crashes.
The crashes are due to the Android loader using the 0.9.8 version of
the library (already mapped from Zygote), and not your version of
OpenSSL.
You can use a shared object, but your shared object must be a wrapper around the static version of libssl
and libcrypto
.
You mentioned that the app loads properly in old devices but crashes in new devices. If the new devices are linking against OpenSSL v1.0.1 and the old ones against v0.9.8, then this might be the root cause of your problem.
The solution seems to be either to compile against static libraries for libcrypto
(and for libssl
too, apparently), or to rename these dependencies after the build, then copy them into your precompiled
directory (if I interpreted the answer in the link correctly):
The reason is that the system comes with its own (probably different)
version of these shared libraries, and the loader will use
/system/lib/libssl.so
and /system/lib/libcrypto.so
instead of your
private copies.