diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2022-09-30 12:57:10 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-10-21 02:33:42 +0000 |
commit | 97866ffe4a0a625b45c88f5bc0bc35fe1df4ffe6 (patch) | |
tree | 94818b358c25f30b55a528fc4eef0fe565183a75 | |
parent | 6a0bba44c2db11f4696aac1ce86e41102258c2b5 (diff) | |
download | qtbase-97866ffe4a0a625b45c88f5bc0bc35fe1df4ffe6.tar.gz |
Android: fix Gradle warning about using enableUncompressedNativeLibs
The warning is as follows:
WARNING:The option setting
'android.bundle.enableUncompressedNativeLibs=false' is deprecated.
The current default is 'true'.
It will be removed in version 8.0 of the Android Gradle plugin.
You can add the following to your build.gradle instead:
android {
packagingOptions {
jniLibs {
useLegacyPackaging = true
}
}
}
We already define that property in build.gradle, but we also need to
account for cases where an old build.gradle file that doesn't have that
property is used. So androiddeployqt checks if useLegacyPackaging is set
(and not commented out) whether it's true or false, if it's set to true,
then that's what Qt wants to set, and if it's set to false, then we
assume the user setting it to false is explicit and we don't want to
change that.
Fixes: QTBUG-106713
Change-Id: I566232207c458daa4484623beee670c6c6679313
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
(cherry picked from commit 466a03e724aa39f7c57010cc2263adb06976ea50)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/tools/androiddeployqt/main.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 6b6f472f66..d42f05f4c7 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -2579,6 +2579,24 @@ void checkAndWarnGradleLongPaths(const QString &outputDirectory) } #endif +bool gradleSetsLegacyPackagingProperty(const QString &path) +{ + QFile file(path); + if (!file.open(QIODevice::ReadOnly)) + return false; + + const auto lines = file.readAll().split('\n'); + for (const auto &line : lines) { + if (line.contains("useLegacyPackaging")) { + const auto trimmed = line.trimmed(); + if (!trimmed.startsWith("//") && !trimmed.startsWith('*') && !trimmed.startsWith("/*")) + return true; + } + } + + return false; +} + bool buildAndroidProject(const Options &options) { GradleProperties localProperties; @@ -2587,9 +2605,13 @@ bool buildAndroidProject(const Options &options) if (!mergeGradleProperties(localPropertiesPath, localProperties)) return false; - QString gradlePropertiesPath = options.outputDirectory + "gradle.properties"_L1; + const QString gradlePropertiesPath = options.outputDirectory + "gradle.properties"_L1; GradleProperties gradleProperties = readGradleProperties(gradlePropertiesPath); - gradleProperties["android.bundle.enableUncompressedNativeLibs"] = "false"; + + const QString gradleBuildFilePath = options.outputDirectory + "build.gradle"_L1; + if (!gradleSetsLegacyPackagingProperty(gradleBuildFilePath)) + gradleProperties["android.bundle.enableUncompressedNativeLibs"] = "false"; + gradleProperties["buildDir"] = "build"; gradleProperties["qtAndroidDir"] = (options.qtInstallDirectory + "/src/android/java"_L1).toUtf8(); // The following property "qt5AndroidDir" is only for compatibility. |