Reputation: 337
I have a weird error where it says:
java.lang.UnsatisfiedLinkError: dlopen failed: cannot find "./obj/local/armeabi-v7a/libsharedlibrary.so" from verneed[1] in DT_NEEDED list for "/data/data/com.my.app/cache/libnative.so"
I have tried a lot, but I don't understand it. I hope anyone out there can help me! Thanks in advance!
EDIT: It is not a diplicate of this question, as it is not the same error. The answer on that question does not help me...
Upvotes: 3
Views: 7669
Reputation: 10499
libsharedlibrary.so is missing its SONAME entry. You probably currently see something like the following:
$ readelf -dW libnative.so | grep NEEDED | grep libsharedlibrary
0x0000000000000001 (NEEDED) Shared library: [./obj/local/armeabi-v7a/libsharedlibrary.so]
Note that if you don't have readelf on your system it is provided in the NDK as $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-readelf (adjust the path as necessary for your OS). Note that the architecture here doesn't actually matter. readelf is a multi-arch tool. Any toolchain's readelf will work fine.
What you should see if libsharedlibrary.so was built with SONAME is:
$ readelf -dW libnative.so | grep NEEDED | grep libsharedlibrary
0x0000000000000001 (NEEDED) Shared library: [libsharedlibrary.so]
You should see the following on libsharedlibrary.so:
$ readelf -dW libsharedlibrary.so | grep SONAME
0x000000000000000e (SONAME) Library soname: [libsharedlibrary.so]
The problem is that libsharedlibrary.so was not built with the -Wl,-soname,libsharedlibrary.so
ldflag. ndk-build and CMake will do that for you, but if you're using a standalone toolchain or a custom build system then you need to provide it yourself.
If the library was built by a third-party and you're not able to rebuild it yourself, I don't think there's anything you can do. You'll need to contact the vendor and report the bug so they can fix it.
Upvotes: 10