Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Deploy Qml Plugin on Android device
Forum Updated to NodeBB v4.3 + New Features

Deploy Qml Plugin on Android device

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 3 Posters 5.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    synasius
    wrote on last edited by
    #1

    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 plugin

    uri = MyTools.Comp

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

    Input

    SOURCES +=
    mytools_plugin.cpp
    tool.cpp
    rotate.cpp

    HEADERS +=
    mytools_plugin.h
    tool.h
    rotate.h

    OTHER_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

    1 Reply Last reply
    1
    • M Offline
      M Offline
      moldovan.catalin
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ayberkozgur
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          synasius
          wrote on last edited by
          #4

          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@

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved