From dea8706c41e8a04fd35262540728aa84b55364ad Mon Sep 17 00:00:00 2001 From: Abhi <85984486+AbhiTheModder@users.noreply.github.com> Date: Fri, 31 Oct 2025 12:22:58 +0530 Subject: [PATCH 1/2] Merge application elements from fusedModules under main - fixes https://github.com/REAndroid/APKEditor/issues/214 --- .../java/com/reandroid/apk/ApkModule.java | 2 ++ .../arsc/chunk/xml/AndroidManifestBlock.java | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/main/java/com/reandroid/apk/ApkModule.java b/src/main/java/com/reandroid/apk/ApkModule.java index 084c78d2d..79ec26d3f 100644 --- a/src/main/java/com/reandroid/apk/ApkModule.java +++ b/src/main/java/com/reandroid/apk/ApkModule.java @@ -37,6 +37,7 @@ import com.reandroid.arsc.chunk.TypeBlock; import com.reandroid.arsc.chunk.xml.AndroidManifestBlock; import com.reandroid.arsc.chunk.xml.ResXmlDocument; +import com.reandroid.arsc.chunk.xml.ResXmlElement; import com.reandroid.arsc.container.SpecTypePair; import com.reandroid.arsc.item.TableString; import com.reandroid.arsc.model.FrameworkTable; @@ -1251,6 +1252,7 @@ private void mergeFusedModules(ApkModule module) { baseManifest.addFusedModuleNames(split); logMessage("Added as fused module <" + split + ">"); } + baseManifest.mergeApplicationElements(manifest); } private void validateMerge(ApkModule apkModule, boolean force) throws IOException{ if (!hasTableBlock()) { diff --git a/src/main/java/com/reandroid/arsc/chunk/xml/AndroidManifestBlock.java b/src/main/java/com/reandroid/arsc/chunk/xml/AndroidManifestBlock.java index 4aff0dd2f..9df3880d0 100644 --- a/src/main/java/com/reandroid/arsc/chunk/xml/AndroidManifestBlock.java +++ b/src/main/java/com/reandroid/arsc/chunk/xml/AndroidManifestBlock.java @@ -22,6 +22,7 @@ import com.reandroid.arsc.io.BlockReader; import com.reandroid.arsc.model.ResourceEntry; import com.reandroid.arsc.value.ValueType; +import com.reandroid.json.JSONObject; import com.reandroid.utils.ObjectsUtil; import com.reandroid.utils.StringsUtil; import com.reandroid.utils.collection.ArrayCollection; @@ -146,6 +147,31 @@ public String[] getFusedModuleNames() { } return null; } + public void mergeApplicationElements(AndroidManifestBlock other) { + if (other == null) { + return; + } + ResXmlElement otherApplication = other.getApplicationElement(); + if (otherApplication == null) { + return; + } + ResXmlElement thisApplication = getOrCreateApplicationElement(); + + Iterator elements = otherApplication.getElements(); + while (elements.hasNext()) { + ResXmlElement otherElement = elements.next(); + String tagName = otherElement.getName(); + if (TAG_meta_data.equals(tagName)) { + String nameValue = getAndroidNameValue(otherElement); + if (VALUE_com_android_dynamic_apk_fused_modules.equals(nameValue)) { + continue; + } + } + JSONObject json = otherElement.toJson(); + ResXmlElement newElement = thisApplication.newElement(); + newElement.fromJson(json); + } + } public void addFusedModuleNames(String ... names) { if (names == null || names.length == 0) { return; From cb85b7beba697b4c81b8e7265db995cffe771ef2 Mon Sep 17 00:00:00 2001 From: Abhi <85984486+AbhiTheModder@users.noreply.github.com> Date: Fri, 31 Oct 2025 12:24:27 +0530 Subject: [PATCH 2/2] remove leftover from old tries --- src/main/java/com/reandroid/apk/ApkModule.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/reandroid/apk/ApkModule.java b/src/main/java/com/reandroid/apk/ApkModule.java index 79ec26d3f..e8511fc8b 100644 --- a/src/main/java/com/reandroid/apk/ApkModule.java +++ b/src/main/java/com/reandroid/apk/ApkModule.java @@ -37,7 +37,6 @@ import com.reandroid.arsc.chunk.TypeBlock; import com.reandroid.arsc.chunk.xml.AndroidManifestBlock; import com.reandroid.arsc.chunk.xml.ResXmlDocument; -import com.reandroid.arsc.chunk.xml.ResXmlElement; import com.reandroid.arsc.container.SpecTypePair; import com.reandroid.arsc.item.TableString; import com.reandroid.arsc.model.FrameworkTable;