Fixed issues related to apks without res directory.

This commit is contained in:
Ryszard Wiśniewski 2010-06-12 16:58:15 +02:00
parent 4af9f005b1
commit 80c9806214
2 changed files with 13 additions and 6 deletions

View File

@ -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";

View File

@ -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);