使用ANDROID_DEPLOYMENT_DEPENDENCIES时,如何在pro文件中引入Fluid QML插件?
Let's break down how to resolve this issue where your manually specified ANDROID_DEPLOYMENT_DEPENDENCIES isn't properly including the Fluid QML plugin, leading to component load failures.
Common Causes & Solutions
1. Deploy All Required Plugin Files
When using ANDROID_DEPLOYMENT_DEPENDENCIES, you're only specifying the shared library (.so) — but the Fluid plugin also needs its QML files and qmldir manifest to be deployed to the device. Add both in your .pro file with this configuration:
# Specify the Fluid plugin's shared library ANDROID_DEPLOYMENT_DEPENDENCIES += $$[QT_INSTALL_QML]/Fluid/libfluid.so # Deploy the plugin's QML files and qmldir to the correct device path android_deployment_resources.files += $$[QT_INSTALL_QML]/Fluid/*.qml \ $$[QT_INSTALL_QML]/Fluid/qmldir android_deployment_resources.path = /qml/Fluid # Matches Qt's default QML import path on Android DEPLOYMENT += android_deployment_resources
The $$[QT_INSTALL_QML] variable pulls the exact path to your Qt 5.11.0 android_armv7 QML directory, avoiding hardcoded path errors.
2. Verify QML Import Paths
Make sure your project tells the QML engine where to look for the Fluid module. Add this line to your .pro file:
QML_IMPORT_PATH += $$[QT_INSTALL_QML]
This ensures the engine can locate the qmldir file for the Fluid plugin during runtime.
3. Confirm Plugin Compatibility
Double-check that the Fluid plugin you installed was compiled with Qt 5.11.0 for Android armv7 — mismatched Qt versions or architectures will cause the plugin to fail loading silently (or with vague errors like the one you're seeing).
4. Debug the Exact Load Error
To get concrete details about why the engine is failing, add debug output to your C++ code:
#include <QQmlApplicationEngine> #include <QDebug> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; // Print available import paths to verify qDebug() << "QML Import Paths:" << engine.importPaths(); // Print available modules (if any) qDebug() << "Available QML Modules:" << engine.availableModules(); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) { // Print specific errors from the engine qDebug() << "QML Load Errors:" << engine.errors(); return -1; } return app.exec(); }
This will show you exactly which module is missing, or if there's a path mismatch preventing the engine from finding Fluid.
5. Check for Missing Dependencies
If you're using ANDROID_DEPLOYMENT_DEPENDENCIES to reduce APK size by skipping auto-deployed libraries, make sure you haven't excluded any Qt core libraries that Fluid depends on. You can check Fluid's dependencies using the NDK's arm-linux-androideabi-readelf tool with the command:
arm-linux-androideabi-readelf -d Qt/5.11.0/android_armv7/qml/Fluid/libfluid.so
This will list all shared libraries the plugin requires — ensure each one is included in your ANDROID_DEPLOYMENT_DEPENDENCIES.
内容的提问来源于stack exchange,提问作者Edip Ahmet

