0

I have an alljoyn library in my project to pair android devices for a voting app. In old devices the app runs properly but in new devices it stops when it is starting to run.

This is the error, I got:

Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libcrypto.so" not found
                      at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
                      at java.lang.System.loadLibrary(System.java:1657)
                      at com.example.nima.voting.alljoyn.peergroupmanager.PeerGroupManager.<clinit>(PeerGroupManager.java:60)
Seanny123
  • 8,776
  • 13
  • 68
  • 124
nima
  • 3
  • 2
  • How are you importing libcrypto.so into PeerGroupManager.java? Include the import statement in the body of your question. – Richie Thomas Jul 28 '18 at 20:31
  • static { System.loadLibrary("alljoyn_java"); } – nima Jul 29 '18 at 05:24
  • which alljoyn version are you using? on which Android version the app does not work? – Lino Jul 30 '18 at 14:14
  • If the below answer solved your problem, please consider marking it as the selected answer. If not, consider specifying why it wasn't helpful, so we can continue helping you solve your issue. – Richie Thomas Aug 01 '18 at 02:57

1 Answers1

0

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.

Richie Thomas
  • 3,073
  • 4
  • 32
  • 55
  • Actually I rerun an old project which is running perfectly in android lollipop and older version, but it crashes with mentioned error in later android version. – nima Aug 05 '18 at 10:32
  • As I mentioned in my answer, the solution seems to be either to compile against static libraries for `libcrypto` and `libssl`, or to rename these dependencies after the build, then copy them into your `precompiled` directory. See the link at the start of my answer for more complete context. – Richie Thomas Aug 05 '18 at 20:45