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/ (dlopen failed: library "assets:/plugins/MyTools/Comp/" not found) @

    this is the
    @TEMPLATE = lib
    TARGET = $$qtLibraryTarget(mytools)
    QT += qml quick widgets
    CONFIG += qt c++11 plugin

    uri = MyTools.Comp

    DESTDIR = ../plugins/$$replace(uri, \., /)


    SOURCES +=

    HEADERS +=

    OTHER_FILES = qmldir

    qmldir.files = qmldir

    android {
    target.path = /assets/plugins/$$replace(uri, \., /)
    qmldir.path = /assets/plugins/$$replace(uri, \., /)

    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
    #ifdef Q_OS_LINUX

    return app.exec();


    The application works on Desktop.
    Any ideas?


  • 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!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/

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.