Cannot load library on Android devices < 5.x.x (API <21)
-
Hello everybody.
My project structure is as follows (root .pro file):
(the actual naming, i.e. lib0, lib1, etc... is different in my project)SUBDIRS += \ module/shared-lib0 \ module/shared-lib1 \ module/shared-lib2 \ module/shared-lib3 # C++ QML plugins SUBDIRS += \ qml/Plugin0 \ qml/Plugin1 \ # apps (executables, including test ones) SUBDIRS += \ app/myapp
In my app/myapp .pro i have defined the qmake variable:
ANDROID_EXTRA_PLUGINS += \ $$DESTDIR/qml/Plugin0 \ $$DESTDIR/qml/Plugin1
I am also enabling my custom plugins in the execution of main:
/* * ENABLE CUSTOM PLUGINS */ frontend.engine()->addImportPath(QString("assets:/")); frontend.engine()->addPluginPath(QCoreApplication::applicationDirPath());
When I run my app against API >=21, everything seems to be deployed correctly - the app is working as expected.
But, when the application is deployed to a device that runs API < 21, I get the following error, which is followed by app crash:W/dalvikvm( 4700): threadid=12: thread exiting with uncaught exception (group=0x4106a438) E/AndroidRuntime( 4700): FATAL EXCEPTION: qtMainLoopThread E/AndroidRuntime( 4700): java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]: 151 could not load needed library 'libshared-lib2.so' for 'libmyapp.so' (load_library[1093]: Library 'libshared-lib2.so' not found) E/AndroidRuntime( 4700): at java.lang.Runtime.load(Runtime.java:340) E/AndroidRuntime( 4700): at java.lang.System.load(System.java:521) E/AndroidRuntime( 4700): at org.qtproject.qt5.android.QtNative$5.run(QtNative.java:341) E/AndroidRuntime( 4700): at org.qtproject.qt5.android.QtThread$2.run(QtThread.java:87) E/AndroidRuntime( 4700): at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61) E/AndroidRuntime( 4700): at java.lang.Thread.run(Thread.java:856)
I can remedy this by explicity loading the libraries in the main activity, i.e. (onCreate method - Java side):
... System.loadLibrary("shared-lib2"); ...
(I have also loaded the plugin libraries explicity, with the correct order.)
Although on some devices (API < 21) it seems to work (tried 4.1.2), while on others I get errors due to custom plugins loading (tried 4.2.2):... too many libraries when loading "libqmlplugin0.so" ...
and tons of warnings regarding the libEGL:
libEGL ( 2237): no more slots for ....
I am targeting API >=16 (as per minimum requirements).
Using Qt 5.12.0, Clang compiler armeabi-v7a.I have searched the www for any information, but came up empty...
Does anybody have any suggestions or steps I could take to remedy this?
Thank you and best regards,
K