Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom QML module deployment to Android: QML dependencies missing

Im developing a custom QML module (let's call it MyModule) containing some special types. It is used as precompiled library on other application projects (i.e. the source code is not available to them, it's used via import MyModule 1.0, setting the necessary import paths etc.). The module contains C++-bases QML types as well as QML files that themselves import QtQuick modules like QtQuick.Controls and QtQuick.Window.

When I try to deploy and execute an application developed using MyModule to Android, the dependencies of MyModule are not picked up by androiddeployqt/qmlimportscanner and included in the APK, which results in messages like: module "QtQuick.Controls" is not installed

Is there a way to have these QML dependencies included in the APK without having to create a dummy qml file containing all imports in the applications source directory, so they can be picked up by qmlimportscanner?

like image 798
Yves Avatar asked Feb 16 '26 06:02

Yves


1 Answers

You can try adding the depends keyword to your qmldir file:

Declares that this module depends on another.

Example:

depends MyOtherModule 1.0

This declaration is necessary only in cases when the dependency is hidden: for example, when the C++ code for one module is used to load QML (perhaps conditionally) which then depends on other modules. In such cases, the depends declaration is necessary to include the other modules in application packages.

For some inspiration, check out this one:

http://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/src/imports/controls/qmldir

like image 69
Mitch Avatar answered Feb 18 '26 20:02

Mitch