From 9622b4b6819ed48631ed0fd25a7e64096d7a92ee Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Mon, 12 May 2025 15:54:50 -0700 Subject: [PATCH] Update the `zipalign` implementation to properly align APKs with uncompressed `.so` libraries --- platform/android/export/export_plugin.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 968d4592cc..4a3b1fc098 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -3818,6 +3818,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref Align long new_offset = file_offset + bias; padding = (ZIP_ALIGNMENT - (new_offset % ZIP_ALIGNMENT)) % ZIP_ALIGNMENT; + const char *ext = strrchr(fname, '.'); + if (ext && strcmp(ext, ".so") == 0) { + padding = (PAGE_SIZE_KB - (new_offset % PAGE_SIZE_KB)) % PAGE_SIZE_KB; + } else { + padding = (ZIP_ALIGNMENT - (new_offset % ZIP_ALIGNMENT)) % ZIP_ALIGNMENT; + } } memset(extra + info.size_file_extra, 0, padding);