Skip to content

Commit

Permalink
Merge pull request #85 from Kirlif/sanitize_manifest_when_merging
Browse files Browse the repository at this point in the history
Remove splitTypes attributes from manifest when merging
  • Loading branch information
REAndroid authored Jan 9, 2024
2 parents 06916e4 + cff8770 commit c8d4679
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ public static List<ResXmlElement> listSplitRequired(ResXmlElement parentElement)
}));
}

public static void removeAttributeFromManifestByName(AndroidManifestBlock androidManifestBlock,
String resourceName, APKLogger logger){
ResXmlElement manifestElement = androidManifestBlock.getManifestElement();
if(manifestElement == null){
if(logger != null){
logger.logMessage("WARN: AndroidManifest don't have <manifest>");
}
return;
}
int removed = manifestElement.removeAttributesWithName(resourceName);
if (removed > 0 && logger != null) {
logger.logMessage("Removed-attribute : " + resourceName);
}
}

public static void removeAttributeFromManifestAndApplication(AndroidManifestBlock androidManifestBlock,
int resourceId, APKLogger logger, String nameForLogging){
if(resourceId == 0){
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/reandroid/apkeditor/merge/Merger.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ private void sanitizeManifest(ApkModule apkModule) {
}
AndroidManifestBlock manifest = apkModule.getAndroidManifest();
logMessage("Sanitizing manifest ...");
AndroidManifestHelper.removeAttributeFromManifestByName(manifest,
AndroidManifest.NAME_requiredSplitTypes, this);
AndroidManifestHelper.removeAttributeFromManifestByName(manifest,
AndroidManifest.NAME_splitTypes, this);
AndroidManifestHelper.removeAttributeFromManifestAndApplication(manifest,
AndroidManifest.ID_extractNativeLibs,
this, AndroidManifest.NAME_extractNativeLibs);
Expand Down

0 comments on commit c8d4679

Please sign in to comment.