This code will not work on a web server because $HOME is set to /var/www/ and
that is not writable (nor do we wish to make it writable)
I added a way to specify the framework folder - please merge this patch into
the trunk :-)
Thanks!
---- START PATCH ----
diff --git a/apktool-cli/src/main/java/brut/apktool/Main.java
b/apktool-cli/src/main/java/brut/apktool/Main.java
index 0963c01..ae7064d 100644
--- a/apktool-cli/src/main/java/brut/apktool/Main.java
+++ b/apktool-cli/src/main/java/brut/apktool/Main.java
@@ -96,6 +96,10 @@ public class Main {
decoder.setDecodeResources(ApkDecoder.DECODE_RESOURCES_NONE);
} else if ("--keep-broken-res".equals(opt)) {
decoder.setKeepBrokenResources(true);
+ } else if ("--framework".equals(opt)) {
+ i++;
+ System.out.println("Using Framework Directory: " + args[i]);
+ decoder.setFrameworkDir(args[i]);
} else {
throw new InvalidArgsError();
}
@@ -223,6 +227,8 @@ public class Main {
" Force delete destination directory.\n" +
" -t <tag>, --frame-tag <tag>\n" +
" Try to use framework files tagged by <tag>.\n" +
+ " --framework <dir>\n" +
+ " Use the specified directory for framework files" +
" --keep-broken-res\n" +
" Use if there was an error and some resources were dropped, e.g.:\n" +
" \"Invalid config flags detected. Dropping resources\", but you\n" +
diff --git a/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java
b/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java
index 8d74e5c..f479b19 100644
--- a/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java
+++ b/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java
@@ -137,6 +137,10 @@ public class ApkDecoder {
public void setKeepBrokenResources(boolean keepBrokenResources) {
mKeepBrokenResources = keepBrokenResources;
}
+
+ public void setFrameworkDir(String dir) {
+ mFrameworkDir = dir;
+ }
public ResTable getResTable() throws AndrolibException {
if (mResTable == null) {
@@ -145,6 +149,7 @@ public class ApkDecoder {
"Apk doesn't containt resources.arsc file");
}
AndrolibResources.sKeepBroken = mKeepBrokenResources;
+ AndrolibResources.sFrameworkFolder = mFrameworkDir;
mResTable = mAndrolib.getResTable(mApkFile);
mResTable.setFrameTag(mFrameTag);
}
@@ -231,4 +236,5 @@ public class ApkDecoder {
private boolean mForceDelete = false;
private String mFrameTag;
private boolean mKeepBrokenResources = false;
+ private String mFrameworkDir = null;
}
diff --git a/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java
b/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java
index 86bda2c..0aabb59 100644
--- a/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java
+++ b/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java
@@ -466,10 +466,13 @@ final public class AndrolibResources {
}
private File getFrameworkDir() throws AndrolibException {
- File dir = new File(System.getProperty("user.home") +
+ File dir = new File(sFrameworkFolder != null ? sFrameworkFolder :
System.getProperty("user.home") +
File.separatorChar + "apktool" + File.separatorChar + "framework");
if (! dir.exists()) {
if (! dir.mkdirs()) {
+ if (sFrameworkFolder != null) {
+ System.out.println("Can't create Framework directory: "
+ dir);
+ }
throw new AndrolibException("Can't create directory: " + dir);
}
}
@@ -487,6 +490,7 @@ final public class AndrolibResources {
// TODO: dirty static hack. I have to refactor decoding mechanisms.
public static boolean sKeepBroken = false;
+ public static String sFrameworkFolder = null;
private final static Logger LOGGER =
Original issue reported on code.google.com by KinkyMun...@gmail.com on 6 Jun 2011 at 5:01
Original issue reported on code.google.com by
KinkyMun...@gmail.com
on 6 Jun 2011 at 5:01