Deploy Qml Plugin on Android device
-
Hi all,
I recently created a custom QML C++ plugin named mytools.
I'm trying to deploy a QML Application that uses the aforementioned plugin to a real android device, but I cant get it to work.Follows the error from the Application Output
@W/Qt (25269): assets:/qml/myapp/main.qml:2 ((null)): assets:/qml/myapp/main.qml:2:1: plugin cannot be loaded for module "MyTools.Comp": Cannot load library assets:/plugins/MyTools/Comp/libmytools.so: (dlopen failed: library "assets:/plugins/MyTools/Comp/libmytools.so" not found) @this is the mytools.pro:
@TEMPLATE = lib
TARGET = $$qtLibraryTarget(mytools)
QT += qml quick widgets
CONFIG += qt c++11 pluginuri = MyTools.Comp
DESTDIR = ../plugins/$$replace(uri, \., /)
Input
SOURCES +=
mytools_plugin.cpp
tool.cpp
rotate.cppHEADERS +=
mytools_plugin.h
tool.h
rotate.hOTHER_FILES = qmldir
qmldir.files = qmldir
android {
target.path = /assets/plugins/$$replace(uri, \., /)
qmldir.path = /assets/plugins/$$replace(uri, \., /)export(target.path) INSTALLS += target qmldir
} else:unix {
installPath = $$[QT_INSTALL_QML]/$$replace(uri, \., /)
qmldir.path = $$installPath
target.path = $$installPath
INSTALLS += target qmldir
}
@In the main.cpp of myapp application I add the assets/plugin directory to the import path:
@int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QtQuick2ApplicationViewer viewer;
#ifdef Q_OS_ANDROID
viewer.engine()->addImportPath("assets:/plugins/");
#endif
#ifdef Q_OS_LINUX
viewer.engine()->addImportPath("../plugins/");
#endif
viewer.setMainQmlFile(QStringLiteral("qml/myapp/main.qml"));
viewer.showExpanded();return app.exec();
}
@The application works on Desktop.
Any ideas?TIA
-
I'm having a similar problem with the Qt3D plugin. It works on desktop but on android I get this application output:
@W/Qt (23581): qml\qqmlapplicationengine.cpp:133 (void QQmlApplicationEnginePrivate::_q_finishLoad(QObject*)): QQmlApplicationEngine failed to load component
W/Qt (23581): qml\qqmlapplicationengine.cpp:134 (void QQmlApplicationEnginePrivate::_q_finishLoad(QObject*)): qrc:///main.qml:2 module "Qt3D" plugin "qthreedqmlplugin" not found
W/Qt (23581):"org.qtproject.example.AndroidQt3D" terminated.@
Have you managed to resolve the issue?
-
We managed to get our QML plugin working with Qt 5.3 via deploying it inside the private Qt qml directory (where official Qt QML modules reside) after having similar issues as above. Please see https://groups.google.com/forum/#!msg/android-qt/fiXNLvfefW8/BBRvreDh2rkJ.
-
I managed to solve this problem adding the following to the .pro file of the main application:
@ANDROID_EXTRA_LIBS += $$OUT_PWD/../plugins/MyTools/Comp/libmytools.so@