4rtzel / cmake-qml-plugin-example

QML plugin example written with CMake
61 stars 16 forks source link

Support for Android #3

Open seijikun opened 4 years ago

seijikun commented 4 years ago

Hey! Thank you for this example using CMake. That really helps, since the original documentation is qmake only.

I added support for building for Android (diff). Though, unfortunately, the plugin is not properly deployed, so the app crashes on startup. During build I see this:

Warning: QML import could not be resolved in any of the import paths: my.plugin.example
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Universal.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Fusion.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Material.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Imagine.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Imagine.impl

and the app crashes with:

W libapp.so: QQmlApplicationEngine failed to load component
W libapp.so: qrc:/main.qml:6 module "my.plugin.example" is not installed

I've tried for several hours, but I don't know enough about how all of this qml module stuff works behind the scenes, so I was not able to fix it. Maybe you could help here?

4rtzel commented 4 years ago

I've never tested this on Android, unfortunately. I remember trying to run a simple Qt app on Andriod (without any plugins) and the setup was rather tricky. Anyway, here are a couple of ideas:

From the look of the errors you posted, it seems that the Android app wasn't able to find the plugin library. You can try QT_DEBUG_PLUGINS and QML_IMPORT_TRACE environment variables to make Qt spew out some more information about the plugin loading but I'm not sure if it will work on Android.

Have you tried following the Qt's official guide for Android app development (https://doc.qt.io/qtcreator/qt-creator-accelbubble-example.html). It seems that CMake is officially supported as a build system so you might want to try to use the project from their documentation as a skeleton. After you make sure you could deploy it as an Android app, you then could start adding the plugin code from this project.

I hope this helps, @seijikun!