diff --git a/CHANGES b/CHANGES index 4bab10a1..2ebefb87 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,10 @@ -v1.5.1 PR2 (TBA) +v1.5.1 PR3 (TBA) +-Reverted "Prevents removal of on decompile, but then throws warning on rebuild (issue #366)" +-Added -a / -aapt command on rebuild to specify location of aapt +-Updated internal framework +-Updated unit tests for 4.2 support + +v1.5.1 PR2 (Released December 19 - 2012) Codename: Pre Release 2 -Closed file-handler when writing frameworks to file system. -Updated to Gradle 1.3 -Properly deleted tmp files after building apk (issue #365) diff --git a/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java b/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java index 07c11e26..cdb377dc 100644 --- a/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java +++ b/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java @@ -113,7 +113,7 @@ public class Main { decoder.setDecodeResources(ApkDecoder.DECODE_RESOURCES_NONE); } else if ("--keep-broken-res".equals(opt)) { decoder.setKeepBrokenResources(true); - } else if ("--framework".equals(opt)) { + } else if ("--frame-path".equals(opt)) { i++; System.out.println("Using Framework Directory: " + args[i]); decoder.setFrameworkDir(args[i]); @@ -172,6 +172,7 @@ public class Main { int i; int skip = 0; ExtFile mOrigApk = null; + String mAaptPath = null; for (i = 0; i < args.length; i++) { String opt = args[i]; if (! opt.startsWith("-")) { @@ -183,6 +184,9 @@ public class Main { flags.put("debug", true); } else if ("-v".equals(opt) || "--verbose".equals(opt)) { flags.put("verbose", true); + } else if ("-a".equals(opt) || "--aapt".equals(opt)) { + mAaptPath = args[i + 1]; + skip = 1; } else if ("-o".equals(opt) || "--original".equals(opt)) { if (args.length >= 4) { throw new InvalidArgsError(); @@ -211,7 +215,7 @@ public class Main { throw new InvalidArgsError(); } - new Androlib().build(new File(appDirName), outFile, flags, mOrigApk); + new Androlib().build(new File(appDirName), outFile, flags, mOrigApk, mAaptPath); } private static void cmdInstallFramework(String[] args) @@ -267,8 +271,8 @@ public class Main { " Force delete destination directory.\n" + " -t , --frame-tag \n" + " Try to use framework files tagged by .\n" + - " --framework \n" + - " Use the specified directory for framework files" + + " --frame-path \n" + + " Use the specified directory for framework files\n" + " --keep-broken-res\n" + " Use if there was an error and some resources were dropped, e.g.:\n" + " \"Invalid config flags detected. Dropping resources\", but you\n" + @@ -291,13 +295,15 @@ public class Main { " Skip changes detection and build all files.\n" + " -d, --debug\n" + " Build in debug mode. Check project page for more info.\n" + + " -a, --aapt\n" + + " Loads aapt from specified location.\n" + // " -o, --original\n" + // " Build resources into original APK. Retains signature." + "\n" + " if|install-framework []\n" + " Install framework file to your system.\n" + "\n" + - "For additional info, see: https://github.com/iBotPeaches/Apktool" + + "For additional info, see: http://code.google.com/p/android-apktool/" + "\n" + "For smali/baksmali info, see: http://code.google.com/p/smali/" ); diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java index c762d757..15af5b47 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java @@ -172,12 +172,14 @@ public class Androlib { } public void build(File appDir, File outFile, - HashMap flags, ExtFile origApk) throws BrutException { - build(new ExtFile(appDir), outFile, flags, origApk); + HashMap flags, ExtFile origApk, String aaptPath) throws BrutException { + build(new ExtFile(appDir), outFile, flags, origApk, aaptPath); } public void build(ExtFile appDir, File outFile, - HashMap flags, ExtFile origApk) throws BrutException { + HashMap flags, ExtFile origApk, String aaptPath) throws BrutException { + + mAaptPath = aaptPath; Map meta = readMetaFile(appDir); Object t1 = meta.get("isFrameworkApk"); flags.put("framework", t1 == null ? false : (Boolean) t1); @@ -335,7 +337,7 @@ public class Androlib { new File(appDir, "AndroidManifest.xml"), new File(appDir, "res"), ninePatch, null, parseUsesFramework(usesFramework), - flags + flags, mAaptPath ); Directory tmpDir = new ExtFile(apkFile).getDirectory(); @@ -398,7 +400,7 @@ public class Androlib { new File(appDir, "AndroidManifest.xml"), null, ninePatch, null, parseUsesFramework(usesFramework), - flags + flags, mAaptPath ); Directory tmpDir = new ExtFile(apkFile).getDirectory(); @@ -450,7 +452,7 @@ public class Androlib { assetDir = null; } mAndRes.aaptPackage(outApk, null, null, - new File(appDir, APK_DIRNAME), assetDir, null, flags); + new File(appDir, APK_DIRNAME), assetDir, null, flags, mAaptPath); @@ -564,6 +566,7 @@ public class Androlib { private ExtFile mOrigApkFile = null; + private String mAaptPath = null; private final static Logger LOGGER = Logger.getLogger(Androlib.class.getName()); 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 3eace961..41816186 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 @@ -266,11 +266,25 @@ final public class AndrolibResources { public void aaptPackage(File apkFile, File manifest, File resDir, File rawDir, File assetDir, File[] include, - HashMap flags) throws AndrolibException { + HashMap flags, String aaptPath) throws AndrolibException { List cmd = new ArrayList(); + + // path for aapt binary + if (!aaptPath.isEmpty()) { + File aaptFile = new File(aaptPath); + if (aaptFile.canRead() && aaptFile.exists()) { + aaptFile.setExecutable(true); + cmd.add(aaptFile.getPath()); + LOGGER.info(aaptFile.getPath() + " being used as aapt location."); + } else { + LOGGER.warning("aapt location could not be found. Defaulting back to default"); + cmd.add("aapt"); + } + } else { + cmd.add("aapt"); + } - cmd.add("aapt"); cmd.add("p"); if (flags.get("verbose")) { // output aapt verbose diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java index e10b22b5..de09e674 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java @@ -45,7 +45,7 @@ public class BuildAndDecodeTest { LOGGER.info("Building testapp.apk..."); ExtFile blank = null; - new Androlib().build(sTestOrigDir, testApk, BuildAndDecodeTest.returnStock(),blank); + new Androlib().build(sTestOrigDir, testApk, BuildAndDecodeTest.returnStock(),blank,""); LOGGER.info("Decoding testapp.apk..."); ApkDecoder apkDecoder = new ApkDecoder(testApk); @@ -118,7 +118,7 @@ public class BuildAndDecodeTest { @Test public void qualifiersTest() throws BrutException { - compareValuesFiles("values-mcc004-mnc4-en-rUS-sw100dp-w200dp-h300dp" + + compareValuesFiles("values-mcc004-mnc4-en-rUS-ldrtl-sw100dp-w200dp-h300dp" + "-xlarge-long-land-desk-night-xhdpi-finger-keyssoft-12key" + "-navhidden-dpad/strings.xml"); } diff --git a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc004-mnc4-en-rUS-sw100dp-w200dp-h300dp-xlarge-long-land-desk-night-xhdpi-finger-keyssoft-12key-navhidden-dpad/strings.xml b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc004-mnc4-en-rUS-ldrtl-sw100dp-w200dp-h300dp-xlarge-long-land-desk-night-xhdpi-finger-keyssoft-12key-navhidden-dpad/strings.xml similarity index 100% rename from brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc004-mnc4-en-rUS-sw100dp-w200dp-h300dp-xlarge-long-land-desk-night-xhdpi-finger-keyssoft-12key-navhidden-dpad/strings.xml rename to brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc004-mnc4-en-rUS-ldrtl-sw100dp-w200dp-h300dp-xlarge-long-land-desk-night-xhdpi-finger-keyssoft-12key-navhidden-dpad/strings.xml