Android application cannot find shared object - android

I have cross-compiled a gstreamer plugin for android. The .so file is installed in the same place as the other gstreamer plugins. I then build an android app having added the cross-compiled plugin name to my Android.mk file (the plugin name is passed to a seperate gstreamer-1.0.mk file to create the libgstandroid.so which is installed alongside the app on the phone).
I'm not yet using the plugin in my application source code, I am just attempting to build/include it in my app as a first step. When the app loads it has a FATAL EXCEPTION:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libgstplugin.so" not found
I'm not sure how to debug; it seems the plugin isn't being linked correctly into the libgstandroid.so?

I was able to solve this problem by building a static plugin library (and deleting the existing shared library as the gstreamer make process seems to choose the .so by default)

Related

LibC++_shared is Present in APK but Not Found When Loading Libraries During Execution?

I'm working on an Android project with a pre-compiled .so file for OpenCV. The original distribution I used as my base (courtesy of QuickBird Studios) contains 2 .so files: libopencv_java4 and libc++_shared. The two .so files are taken from a .aar library which I had to unpack in order to address a known, long-standing issue in the OpenCV Android implementation. These two SOs are stored in the same folder in my project tree, as seen here. The other ABIs share identical structure to arm64-v8a.
When compiling the APK with Intellij IDEA (v2022.1.3), the APK analyzer shows that both .so files have been packaged in to lib/{ABI}, as can be seen here (in this case, the ABI is arm64-v8a). So far, so good.
However, when I go to load the OpenCV library (which calls upon libc++_shared), I receive the following error:
W/System.err: java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found: needed by {omitted}/base.apk/lib/arm64-v8a/libopencv_java4.so in namespace classloader-namespace
I've attempted building the APK without including libstdc++_shared, under the pretense that Gradle claims to be able to include the C++ shared libraries automatically. This failed with the same error message as above, with no libc++_shared.so in the APK.
I've also attempted to create a dummy native C++ file, in order to get libc++_shared added via CMake during the Gradle build process. This also failed with the above error. I did not think to check the APK during this attempt.
In a previous iteration of this project (before I discovered the bug in the OpenCV Android implementation), I was able to compile and run without issue by including the .aar file as an external library.
Between each of the above attempts, I've performed a full Gradle cache invalidation to make sure I'm not keeping broken files from previous tries.
I'm completely flummoxed. Did I break something when I unpacked the .aar to fix the bug? How can I get Android to acknowledge what's inside the APK?
I had the same issue after upgrading the Gradle plugin. the nonsense disappear after I also upgrade the Gradle build tool.
dependencies {
//after upgrad from 3.5.1 the link error disappear
classpath "com.android.tools.build:gradle:3.5.4"
...
}

How to add vendor shared lib to android ndk app

I have added a library under Android aosp vendor folder and successfully created shared lib (lets say, libmyvendor.so) files. And verified that .so files are created under both system/lib and system/lib64. Flashed on a device and working fine here.
To debug my ndk application, I have copied .so files into Android's path sdk/ndk/{versionNumber}/platforms/android-28/arch-x86/usr/lib. Also in archx86_64/usr/lib64 folder. Did invalidate and restart Android Studio. Now I'm trying to find or add libmyvendor library in my ndk application using cmake function
find_library(mVendor libmyvendor)
Tried myvendor instead of libmyvendor. In both cases, cmake couldn't find it.
Then tried copying libmyvendor.so files into ndk application (under jniLibs/x86/ and x86_64/ ). Compiled but app crash at runtime saying
UnSatifiedLinkError: dlopen failed library 'libcrypto.so' not found
Where libcrypto.so is needed as a dependent to libmyvendor project. And I'm stuck here.
As per my assumption, libmyvendor is part of system libs. NDK should be capable of finding it using find_library(), just like we find liblog.so. But it cannot find. Did I miss or mess anything?

Unity DLL Not Found Exception in Android Application

I'm writing an android plugin for Unity, libSolidCapture.so. This plugin is using a shared library, named liblo.so, an OSC library When I'm trying to launch the application on an android device, I get the following error :
Unable to load library '/libSolidCapture.so', native render plugin
support disabled: java.lang.UnsatisfiedLinkError: dlopen failed:
library "liblo.so.7" not found
then :
DllNotFoundException: SolidCapture
When i build liblo for android, liblo.so.7 is created, but when I try to drag and drop it in Unity, it seems to be considered as a folder, and not a library !
When I build an apk, Unity includes liblo.so, but not liblo.so.7
Do you have any idea of what I'm doing wrong ?

Building android app on Qt using additional library (Assimp)

Hi I am trying to port an OpenGL desktop app to android. I have no knowledge of android development so am depending on Qt Creator to package the app. As part of the setup, I have invoked 'make-standalone-toolchain' script in android ndk with following settings
--platform=android-21
--toolchain=arm-linux-androideabi-4.9
--system=linux-x86_64
Then I used android-cmake and passed it the path of my newly created standalone-toolchain, which created libassimp.so, libassimp.so.3, and libassimp.so.3.1.1(ln) inside my assimp directory tree.
I passed the libassimp.so path to Qt creator project build menu under 'additional libraries'. However, on deploying the app on android, it crashes with error:
dlopen("/data/app/org.qtproject.example.a3dqtquick-2/lib/arm/lib3dqtquick.so", RTLD_LAZY) failed: dlopen failed: could not load library "libassimp.so.3" needed by "lib3dqtquick.so"; caused by library "libassimp.so.3" not found
I can even see the libassimp.so (not libassimp.so.3) file inside the project build directory at
../android-build/libs/armeabi-v7a.
Not sure where to go from here, manually placing libassimp.so.3 at this location does not sort out the problem. Thanks for reading. I will add further info on your feedback . please forgive any info deficiency as this is my first experiment with android.
Following is the deployment-settings.json file
"description": "This file is generated by qmake to be read by androiddeployqt and should not be modified by hand.",
"qt": "/home/ubashir/programs/Qt/5.4/android_armv7",
"sdk": "/home/ubashir/programs/android-sdk-linux",
"sdkBuildToolsRevision": "21.1.2",
"ndk": "/home/ubashir/programs/android-ndk-r10d",
"toolchain-prefix": "arm-linux-androideabi",
"tool-prefix": "arm-linux-androideabi",
"toolchain-version": "4.9",
"ndk-host": "linux-x86_64",
"target-architecture": "armeabi-v7a",
"qml-root-path": "/home/ubashir/code/3dqtquick",
"application-binary": "/home/ubashir/code/3dqtquickAndroid/lib3dqtquick.so"
UPDATE:
I have now tried this.. replace all links to assimp.so.3.1.1 with copies of the latter so now my library libassimp.so.3 is a file instead of link to libassimp.so.3.1.1. I manually added libassimp.so.3 to my project subfolder android/libs/aremabi-v71 --- no good. I confirm that my build directory shows all libassimp files as I manually added them so presumably they are being deployed but the error remains :
failed: dlopen failed: could not load library "libassimp.so.3" needed by "lib3dqtquick.so".
As outlined here http://webmail.dev411.com/p/gg/android-ndk/1386vger6e/use-assimp-c-library-in-ndk-ld-error-obj-local-armeabi-v7a-libassimp-so-incompatible-target-for-use-with-vuforia
I even edited the link.txt file after running cmake on my assimp build directory for android, altering the entry -soname,libassimp.so.3 with -soname,libassimp.so but it still creates libassimp.so.3.1.1 with its two links , i.e., libassimp.so.3 and libassimp.so. So still stuck..
I ran into the same problem with a shared library I built with CMake for and Android project. I found a way to fix it. There might be a cleaner solution if you were more familiar with CMake.
Search through the CMakeLists.txt file(s) for "SOVERSION" and "SET_TARGET_PROPERTIES()"
In the SET_TARGET_PROPERTIES() routine comment out the lines for VERSION and SOVERSION as follows
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES # create *nix style library versions + symbolic links
DEFINE_SYMBOL DSO_EXPORTS
# VERSION ${PROJECT_VERSION}
# SOVERSION ${PROJECT_SOVERSION}
CLEAN_DIRECT_OUTPUT 1 # allow creating static and shared libs without conflicts
OUTPUT_NAME "${PROJECT_NAME}${PROJECT_DLLVERSION}" # avoid conflicts between library and binary target names
)
Then rerun the configure and generate steps in CMake and rebuild the target. This should give you a .so without any version numbers.
I'll suggest you to take a look at the solution I've found to my problem (that is very similar to yours):
libgdal.so android error: could not load library "libgdal.so.1"
Hope this helps.

android ndk mupdf build error

I am trying to make a project to read pdf in android phone.
So, I created the normal Android Project and installed the android-ndk-r6-windows.
And I built the 'libmibookreader.so' and set the native functions in my java class.
But after compiling my project I have a serious Error.
Caused by: java.lang.UnsatisfiedLinkError: Library mibookreader not found
Why this error caused?
I really don't know. I referenced the address of "http://flytgr.thoth.kr/blog/697421".
I followed down as the reference document described.
This is because your library was not loaded by the kernel. Are you sure that you placed your library inside the libs/armeabi/ folder of your project?
Check the logcat when you deploy your application, you should see some messages there that your library was loaded.
If you don't you could also try to use System.loadLibrary(libPath); to manually load your library.

Categories

Resources