From 7499fd0229d63f969bf6ca58d3b764b96395bed2 Mon Sep 17 00:00:00 2001 From: Bartlomiej Moskal Date: Tue, 29 Oct 2024 09:25:20 +0100 Subject: [PATCH] AndroidDeployQt: Remove not satisfied dependencies In 438837ce274fdc1457b66179b25df40f33b23a15 commit, we stopped to copy all dependent libs that are kept in plugin directory. This change sounds reasonable, as we do not want to deploy unused libs. Due to the mentioned change, when dependencies.xml contains *.so libraries, they are not copied at all now. They are added to localLibs (later pasted into libs.xml), but are not shipped with the apk. So at the end we have dependencies in libs.xml on some libraries that were not delievered. This commit cleans up the localLibs to not add dependencies to the libs.xml file as they will not be satisfied Fixes: QTBUG-129946 Pick-to: 6.8 Change-Id: I7157e2e65cb928adbe9d7c077e50b2ebcac94490 Reviewed-by: Assam Boudjelthia --- src/tools/androiddeployqt/main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index c3ca363507a..62398537e13 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -1800,10 +1800,21 @@ bool updateLibsXml(Options *options) QStringList localLibs; localLibs = options->localLibs[it.key()]; + const QList& deps = options->qtDependencies[it.key()]; + auto notExistsInDependencies = [&deps] (const QString &lib) { + return std::none_of(deps.begin(), deps.end(), [&lib] (const QtDependency &dep) { + return QFileInfo(dep.absolutePath).fileName() == QFileInfo(lib).fileName(); + }); + }; + + // Clean up localLibs: remove libs that were not added to qtDependecies + localLibs.erase(std::remove_if(localLibs.begin(), localLibs.end(), notExistsInDependencies), + localLibs.end()); + // If .pro file overrides dependency detection, we need to see which platform plugin they picked if (localLibs.isEmpty()) { QString plugin; - for (const QtDependency &qtDependency : options->qtDependencies[it.key()]) { + for (const QtDependency &qtDependency : deps) { if (qtDependency.relativePath.contains("libplugins_platforms_qtforandroid_"_L1)) plugin = qtDependency.relativePath;