use of brut.androlib.err.CantFindFrameworkResException in project Apktool by iBotPeaches.
the class AndrolibResources method getFrameworkApk.
public File getFrameworkApk(int id, String frameTag) throws AndrolibException {
File dir = getFrameworkDir();
File apk;
if (frameTag != null) {
apk = new File(dir, String.valueOf(id) + '-' + frameTag + ".apk");
if (apk.exists()) {
return apk;
}
}
apk = new File(dir, String.valueOf(id) + ".apk");
if (apk.exists()) {
return apk;
}
if (id == 1) {
try (InputStream in = AndrolibResources.class.getResourceAsStream("/brut/androlib/android-framework.jar");
OutputStream out = new FileOutputStream(apk)) {
IOUtils.copy(in, out);
return apk;
} catch (IOException ex) {
throw new AndrolibException(ex);
}
}
throw new CantFindFrameworkResException(id);
}
use of brut.androlib.err.CantFindFrameworkResException in project Apktool by iBotPeaches.
the class Main method cmdDecode.
private static void cmdDecode(CommandLine cli) throws AndrolibException {
ApkDecoder decoder = new ApkDecoder();
int paraCount = cli.getArgList().size();
String apkName = (String) cli.getArgList().get(paraCount - 1);
File outDir;
// check for options
if (cli.hasOption("s") || cli.hasOption("no-src")) {
decoder.setDecodeSources(ApkDecoder.DECODE_SOURCES_NONE);
}
if (cli.hasOption("d") || cli.hasOption("debug")) {
System.err.println("SmaliDebugging has been removed in 2.1.0 onward. Please see: https://github.com/iBotPeaches/Apktool/issues/1061");
System.exit(1);
}
if (cli.hasOption("b") || cli.hasOption("no-debug-info")) {
decoder.setBaksmaliDebugMode(false);
}
if (cli.hasOption("t") || cli.hasOption("frame-tag")) {
decoder.setFrameworkTag(cli.getOptionValue("t"));
}
if (cli.hasOption("f") || cli.hasOption("force")) {
decoder.setForceDelete(true);
}
if (cli.hasOption("r") || cli.hasOption("no-res")) {
decoder.setDecodeResources(ApkDecoder.DECODE_RESOURCES_NONE);
}
if (cli.hasOption("k") || cli.hasOption("keep-broken-res")) {
decoder.setKeepBrokenResources(true);
}
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
decoder.setFrameworkDir(cli.getOptionValue("p"));
}
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);
} else {
// make out folder manually using name of apk
String outName = apkName;
outName = outName.endsWith(".apk") ? outName.substring(0, outName.length() - 4).trim() : outName + ".out";
// make file from path
outName = new File(outName).getName();
outDir = new File(outName);
decoder.setOutDir(outDir);
}
decoder.setApkFile(new File(apkName));
try {
decoder.decode();
} catch (OutDirExistsException ex) {
System.err.println("Destination directory (" + outDir.getAbsolutePath() + ") " + "already exists. Use -f switch if you want to overwrite it.");
System.exit(1);
} catch (InFileNotFoundException ex) {
System.err.println("Input file (" + apkName + ") " + "was not found or was not readable.");
System.exit(1);
} catch (CantFindFrameworkResException ex) {
System.err.println("Can't find framework resources for package of id: " + String.valueOf(ex.getPkgId()) + ". You must install proper " + "framework files, see project website for more info.");
System.exit(1);
} catch (IOException ex) {
System.err.println("Could not modify file. Please ensure you have permission.");
System.exit(1);
} catch (DirectoryException ex) {
System.err.println("Could not modify internal dex files. Please ensure you have permission.");
System.exit(1);
}
}
Aggregations