diff --git a/src/brut/androlib/Androlib.java b/src/brut/androlib/Androlib.java index 11d32b4f..94a3f320 100644 --- a/src/brut/androlib/Androlib.java +++ b/src/brut/androlib/Androlib.java @@ -292,8 +292,10 @@ public class Androlib { false, framework ); - new ExtFile(apkFile).getDirectory() - .copyToDir(apkDir, APK_RESOURCES_FILENAMES); + Directory tmpDir = new ExtFile(apkFile).getDirectory(); + tmpDir.copyToDir(apkDir, + tmpDir.containsDir("res") ? APK_RESOURCES_FILENAMES : + APK_RESOURCES_WITHOUT_RES_FILENAMES); } return true; } catch (IOException ex) { @@ -418,6 +420,8 @@ public class Androlib { private final static String OUT_APK_FILENAME = "dist/out.apk"; private final static String[] APK_RESOURCES_FILENAMES = new String[]{"resources.arsc", "AndroidManifest.xml", "res"}; + private final static String[] APK_RESOURCES_WITHOUT_RES_FILENAMES = + new String[]{"resources.arsc", "AndroidManifest.xml"}; private final static String[] APP_RESOURCES_FILENAMES = new String[]{"AndroidManifest.xml", "res"}; private final static String VERSION = "1.2.0"; diff --git a/src/brut/androlib/res/AndrolibResources.java b/src/brut/androlib/res/AndrolibResources.java index e6d05a1c..9bec86eb 100644 --- a/src/brut/androlib/res/AndrolibResources.java +++ b/src/brut/androlib/res/AndrolibResources.java @@ -104,15 +104,18 @@ final public class AndrolibResources { attrDecoder.setCurrentPackage( resTable.listMainPackages().iterator().next()); - Directory in, out; + Directory inApk, in = null, out; try { - in = apkFile.getDirectory(); + inApk = apkFile.getDirectory(); out = new FileDirectory(outDir); fileDecoder.decode( - in, "AndroidManifest.xml", out, "AndroidManifest.xml", "xml"); + inApk, "AndroidManifest.xml", out, "AndroidManifest.xml", + "xml"); - in = in.getDir("res"); + if (inApk.containsDir("res")) { + in = inApk.getDir("res"); + } out = out.createDir("res"); } catch (DirectoryException ex) { throw new AndrolibException(ex);