fix jar disassembling

This commit is contained in:
Connor Tumbleson 2013-10-16 19:48:43 -05:00
parent 87e39c4bb9
commit 2ef25fe5e2
3 changed files with 25 additions and 5 deletions

View File

@ -25,6 +25,7 @@ v2.0.0 (TBA)
-Fixed (issue #426) - Filename too long (JesusFreke)
-Fixed (issue #524) - INSTALL_FAILED_DEXOPT fix (JesusFreke)
-Fixed (issue #473) - multiple package frameworks are treated correctly.
-Fixed (issue #531) - JAR disassembling borking is fixed
-Added output to list Apktool version to help debugging.
-Updated known bytes for configurations to 38 (from addition of layout direction)
-Fixed NPE when handling odex apks even with --no-src specified. (Thanks Rodrigo Chiossi)

View File

@ -144,6 +144,9 @@ public class Main {
if (cli.hasOption("m") || cli.hasOption("match-original")) {
decoder.setAnalysisMode(true, false);
}
if (cli.hasOption("api")) {
decoder.setApi(Integer.parseInt(cli.getOptionValue("api")));
}
if (cli.hasOption("o") || cli.hasOption("output")) {
outDir = new File(cli.getOptionValue("o"));
decoder.setOutDir(outDir);
@ -295,6 +298,12 @@ public class Main {
.withArgName("prefix")
.create();
Option apiLevelOption = OptionBuilder.withLongOpt("api")
.withDescription("The numeric api-level of the file to generate, e.g. 14 for ICS.")
.hasArg(true)
.withArgName("API")
.create();
Option debugBuiOption = OptionBuilder.withLongOpt("debug")
.withDescription("Builds in debug mode. Check project page for more info.")
.create("d");
@ -377,6 +386,7 @@ public class Main {
DecodeOptions.addOption(noDbgOption);
DecodeOptions.addOption(keepResOption);
DecodeOptions.addOption(analysisOption);
DecodeOptions.addOption(apiLevelOption);
BuildOptions.addOption(debugBuiOption);
BuildOptions.addOption(aaptOption);

View File

@ -64,6 +64,10 @@ public class ApkDecoder {
mOutDir = outDir;
}
public void setApi(int api) {
mApi = api;
}
public void decode() throws AndrolibException, IOException {
File outDir = getOutDir();
@ -85,9 +89,15 @@ public class ApkDecoder {
LOGGER.info("Using Apktool " + Androlib.getVersion() + " on " + mApkFile.getName());
if (hasResources()) {
Map<String, String> sdkInfo = mAndrolib.getResTable(mApkFile).getSdkInfo();
if (sdkInfo.get("targetSdkVersion") != null) {
mApi = Integer.parseInt(sdkInfo.get("targetSdkVersion"));
}
setAnalysisMode(mAnalysisMode, true);
// read the resources.arsc checking for STORED vs DEFLATE
// compression
// this will determine whether we compress on rebuild or not.
ZipExtFile zef = new ZipExtFile(mApkFile.getAbsolutePath());
ZipArchiveEntry ze = zef.getEntry("resources.arsc");
@ -122,8 +132,7 @@ public class ApkDecoder {
}
}
Map<String, String> sdkInfo = mAndrolib.getResTable(mApkFile).getSdkInfo();
int api = (sdkInfo.get("targetSdkVersion") != null) ? Integer.parseInt(sdkInfo.get("targetSdkVersion")) : mDefaultApi;
if (hasSources()) {
switch (mDecodeSources) {
@ -131,7 +140,7 @@ public class ApkDecoder {
mAndrolib.decodeSourcesRaw(mApkFile, outDir, mDebug);
break;
case DECODE_SOURCES_SMALI:
mAndrolib.decodeSourcesSmali(mApkFile, outDir, mDebug, mDebugLinePrefix, mBakDeb, api);
mAndrolib.decodeSourcesSmali(mApkFile, outDir, mDebug, mDebugLinePrefix, mBakDeb, mApi);
break;
case DECODE_SOURCES_JAVA:
mAndrolib.decodeSourcesJava(mApkFile, outDir, mDebug);
@ -359,7 +368,7 @@ public class ApkDecoder {
private String mFrameTag;
private boolean mKeepBrokenResources = false;
private String mFrameworkDir = null;
private int mDefaultApi = 15;
private int mApi = 15;
private boolean mBakDeb = true;
private boolean mCompressResources = false;
private boolean mAnalysisMode = false;