fix: patch aapt2 to not run custom commands on passed aapt2 binary

This commit is contained in:
Connor Tumbleson 2019-11-20 06:37:02 -05:00 committed by Connor Tumbleson
parent d6f38e38cd
commit b05f19b80d

View File

@ -341,7 +341,7 @@ final public class AndrolibResources {
}
private void aapt2Package(File apkFile, File manifest, File resDir, File rawDir, File assetDir, File[] include,
List<String> cmd)
List<String> cmd, boolean customAapt)
throws AndrolibException {
List<String> 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);