From 74eba7a7706607501e8691eeb363a22604e32198 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Wed, 18 Jun 2025 13:19:52 -0700 Subject: [PATCH] Revert the removal of the `gradle_build/compress_native_libraries` export option --- .../doc_classes/EditorExportPlatformAndroid.xml | 5 +++++ platform/android/export/export_plugin.cpp | 10 +++++++++- platform/android/java/app/build.gradle | 8 ++++++++ platform/android/java/app/config.gradle | 17 +++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/platform/android/doc_classes/EditorExportPlatformAndroid.xml b/platform/android/doc_classes/EditorExportPlatformAndroid.xml index b9840154e08..a8400dd89d4 100644 --- a/platform/android/doc_classes/EditorExportPlatformAndroid.xml +++ b/platform/android/doc_classes/EditorExportPlatformAndroid.xml @@ -52,6 +52,11 @@ Path to a ZIP file holding the source for the export template used in a Gradle build. If left empty, the default template is used. + + If [code]true[/code], native libraries are compressed when performing a Gradle build. + [b]Note:[/b] While enabling compression can reduce the size of the binary, it may result in slower application startup because the native libraries must be extracted before use, rather than being loaded directly. + If you're distributing your app via the Play Store, it's generally recommended to keep this option [code]false[/code], see [url=https://developer.android.com/build/releases/past-releases/agp-3-6-0-release-notes#extractNativeLibs]official documentation[/url]. + A dictionary of custom theme attributes to include in the exported Android project. Each entry defines a theme attribute name and its value, and will be added to the [b]GodotAppMainTheme[/b]. For example, the key [code]android:windowSwipeToDismiss[/code] with the value [code]false[/code] is resolved to [code]<item name="android:windowSwipeToDismiss">false</item>[/code]. diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 55b09feb9a9..de5ed44766d 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -2014,6 +2014,11 @@ String EditorExportPlatformAndroid::get_export_option_warning(const EditorExport if (!enabled_deprecated_plugins_names.is_empty() && !gradle_build_enabled) { return TTR("\"Use Gradle Build\" must be enabled to use the plugins."); } + } else if (p_name == "gradle_build/compress_native_libraries") { + bool gradle_build_enabled = p_preset->get("gradle_build/use_gradle_build"); + if (bool(p_preset->get("gradle_build/compress_native_libraries")) && !gradle_build_enabled) { + return TTR("\"Compress Native Libraries\" is only valid when \"Use Gradle Build\" is enabled."); + } } else if (p_name == "gradle_build/export_format") { bool gradle_build_enabled = p_preset->get("gradle_build/use_gradle_build"); if (int(p_preset->get("gradle_build/export_format")) == EXPORT_FORMAT_AAB && !gradle_build_enabled) { @@ -2097,6 +2102,7 @@ void EditorExportPlatformAndroid::get_export_options(List *r_optio r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "gradle_build/use_gradle_build"), false, true, true)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "gradle_build/gradle_build_directory", PROPERTY_HINT_PLACEHOLDER_TEXT, "res://android"), "", false, false)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "gradle_build/android_source_template", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "gradle_build/compress_native_libraries"), false, false, true)); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "gradle_build/export_format", PROPERTY_HINT_ENUM, "Export APK,Export AAB"), EXPORT_FORMAT_APK, false, true)); // Using String instead of int to default to an empty string (no override) with placeholder for instructions (see GH-62465). // This implies doing validation that the string is a proper int. @@ -3580,8 +3586,9 @@ Error EditorExportPlatformAndroid::export_project_helper(const Refget("gradle_build/compress_native_libraries")); Vector android_libraries; Vector android_dependencies; @@ -3656,6 +3663,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref + String legacyPackagingFlag = project.hasProperty("compress_native_libraries") ? project.property("compress_native_libraries") : "" + if (legacyPackagingFlag != null && !legacyPackagingFlag.isEmpty()) { + return Boolean.parseBoolean(legacyPackagingFlag) + } + + // Default behavior for minSdk >= 24 + return false +} + ext.getAddonsDirectory = { -> String addonsDirectory = project.hasProperty("addons_directory") ? project.property("addons_directory") : "" return addonsDirectory