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 false, framework
); );
new ExtFile(apkFile).getDirectory() Directory tmpDir = new ExtFile(apkFile).getDirectory();
.copyToDir(apkDir, APK_RESOURCES_FILENAMES); tmpDir.copyToDir(apkDir,
tmpDir.containsDir("res") ? APK_RESOURCES_FILENAMES :
APK_RESOURCES_WITHOUT_RES_FILENAMES);
} }
return true; return true;
} catch (IOException ex) { } catch (IOException ex) {
@ -418,6 +420,8 @@ public class Androlib {
private final static String OUT_APK_FILENAME = "dist/out.apk"; private final static String OUT_APK_FILENAME = "dist/out.apk";
private final static String[] APK_RESOURCES_FILENAMES = private final static String[] APK_RESOURCES_FILENAMES =
new String[]{"resources.arsc", "AndroidManifest.xml", "res"}; 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 = private final static String[] APP_RESOURCES_FILENAMES =
new String[]{"AndroidManifest.xml", "res"}; new String[]{"AndroidManifest.xml", "res"};
private final static String VERSION = "1.2.0"; private final static String VERSION = "1.2.0";

View File

@ -104,15 +104,18 @@ final public class AndrolibResources {
attrDecoder.setCurrentPackage( attrDecoder.setCurrentPackage(
resTable.listMainPackages().iterator().next()); resTable.listMainPackages().iterator().next());
Directory in, out; Directory inApk, in = null, out;
try { try {
in = apkFile.getDirectory(); inApk = apkFile.getDirectory();
out = new FileDirectory(outDir); out = new FileDirectory(outDir);
fileDecoder.decode( 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"); out = out.createDir("res");
} catch (DirectoryException ex) { } catch (DirectoryException ex) {
throw new AndrolibException(ex); throw new AndrolibException(ex);