mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-05 17:45:52 +01:00
Updated unit-tests for 4.2 APK support, added -a / --apt during build for location to aapt, reverted fix regarding <uses-sdk>
This commit is contained in:
parent
3b0ca62fb0
commit
3b1a8be980
8
CHANGES
8
CHANGES
@ -1,4 +1,10 @@
|
||||
v1.5.1 PR2 (TBA)
|
||||
v1.5.1 PR3 (TBA)
|
||||
-Reverted "Prevents removal of <uses-sdk> 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)
|
||||
|
@ -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 <tag>, --frame-tag <tag>\n" +
|
||||
" Try to use framework files tagged by <tag>.\n" +
|
||||
" --framework <dir>\n" +
|
||||
" Use the specified directory for framework files" +
|
||||
" --frame-path <dir>\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 <framework.apk> [<tag>]\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/"
|
||||
);
|
||||
|
@ -172,12 +172,14 @@ public class Androlib {
|
||||
}
|
||||
|
||||
public void build(File appDir, File outFile,
|
||||
HashMap<String, Boolean> flags, ExtFile origApk) throws BrutException {
|
||||
build(new ExtFile(appDir), outFile, flags, origApk);
|
||||
HashMap<String, Boolean> flags, ExtFile origApk, String aaptPath) throws BrutException {
|
||||
build(new ExtFile(appDir), outFile, flags, origApk, aaptPath);
|
||||
}
|
||||
|
||||
public void build(ExtFile appDir, File outFile,
|
||||
HashMap<String, Boolean> flags, ExtFile origApk) throws BrutException {
|
||||
HashMap<String, Boolean> flags, ExtFile origApk, String aaptPath) throws BrutException {
|
||||
|
||||
mAaptPath = aaptPath;
|
||||
Map<String, Object> 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());
|
||||
|
@ -266,11 +266,25 @@ final public class AndrolibResources {
|
||||
|
||||
public void aaptPackage(File apkFile, File manifest, File resDir,
|
||||
File rawDir, File assetDir, File[] include,
|
||||
HashMap<String, Boolean> flags) throws AndrolibException {
|
||||
HashMap<String, Boolean> flags, String aaptPath) throws AndrolibException {
|
||||
|
||||
List<String> cmd = new ArrayList<String>();
|
||||
|
||||
// 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
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user