diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java index a896bd39..49a5a3a8 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java @@ -341,7 +341,7 @@ final public class AndrolibResources { } private void aapt2Package(File apkFile, File manifest, File resDir, File rawDir, File assetDir, File[] include, - List cmd) + List cmd, boolean customAapt) throws AndrolibException { List compileCommand = new ArrayList<>(cmd); @@ -448,10 +448,17 @@ final public class AndrolibResources { cmd.add("-x"); } - if (apkOptions.doNotCompress != null) { + if (apkOptions.doNotCompress != null && !customAapt) { + // Use custom -e option to avoid limits on commandline length. + // Can only be used when custom aapt binary is not used. String extensionsFilePath = createDoNotCompressExtensionsFile(apkOptions).getAbsolutePath(); cmd.add("-e"); cmd.add(extensionsFilePath); + } else if (apkOptions.doNotCompress != null) { + for (String file : apkOptions.doNotCompress) { + cmd.add("-0"); + cmd.add(file); + } } if (!apkOptions.resourcesAreCompressed) { @@ -627,7 +634,7 @@ final public class AndrolibResources { } if (apkOptions.isAapt2()) { - aapt2Package(apkFile, manifest, resDir, rawDir, assetDir, include, cmd); + aapt2Package(apkFile, manifest, resDir, rawDir, assetDir, include, cmd, customAapt); return; } aapt1Package(apkFile, manifest, resDir, rawDir, assetDir, include, cmd, customAapt);