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>
This commit is contained in:
parent
6a0bba44c2
commit
97866ffe4a
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user