brut.androlib.res.util.ExtFile Java Examples

The following examples show how to use brut.androlib.res.util.ExtFile. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApkToolPlus.java    From ApkToolPlus with Apache License 2.0 6 votes vote down vote up
/**
 *  .smali转换.dex
 *
 * @param smaliDirPath      smali文件目录或zip文件路径
 * @param dexOutputPath     dex文件输出路径
 * @return 是否转换成功
 */
public static boolean smali2dex(String smaliDirPath, String dexOutputPath){
    ExtFile smaliDir = new ExtFile(new File(smaliDirPath));
    if (!smaliDir.exists()){
        LogUtils.w("smali2dex error : smali dir '" + smaliDirPath + "' is not exists");
        return false;
    }

    // 创建输出路径
    if (!FileHelper.makePath(dexOutputPath)){
        LogUtils.w("makePath error : dexOutputPath '" + dexOutputPath + "' make fail");
        return false;
    }

    File dexFile = new File(dexOutputPath);
    dexFile.delete();

    try {
        // smali -> dex
        SmaliBuilder.build(smaliDir, dexFile);
        return true;
    } catch (AndrolibException e) {
        e.printStackTrace();
    }
    return false;
}
 
Example #2
Source File: StringsXML.java    From appium_apk_tools with Apache License 2.0 5 votes vote down vote up
public static void run(final File input, final File outputDirectory,
    String localization) throws Exception {
  if (localization == null) {
    localization = "values";
  }
  final ExtFile apkFile = new ExtFile(input);
  ResTable table = res.getResTable(apkFile, true);
  ResValuesFile stringsXML = null;
  for (ResPackage pkg : table.listMainPackages()) {
    p(pkg);
    for (ResValuesFile values : pkg.listValuesFiles()) {
      // strings.xml is not case sensitive. xamarin will call it Strings.xml
      final String path = values.getPath().toLowerCase();
      final String targetPath = (localization + "/strings.xml").toLowerCase();
      p(path);
      if (path.endsWith(targetPath)) {
        stringsXML = values;
        break;
      }
    }
    if (stringsXML != null) {
      break;
    }
  }

  if (stringsXML == null) {
    e("Could not find the strings.xml file for localization: " + localization);
  }

  toJSON(stringsXML, outputDirectory);
  p("complete");
}
 
Example #3
Source File: AndroidManifestActivityHelper.java    From appium_apk_tools with Apache License 2.0 4 votes vote down vote up
public static void decodeManifestXML(final File input, final File outputDirectory) throws Exception {
 final ExtFile apkFile = new ExtFile(input);
 ResTable table = res.getResTable(apkFile, true);
 res.decodeManifest(table, apkFile, outputDirectory);
}