diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java index 40965bb9..74aba158 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java @@ -72,6 +72,7 @@ public class ApkDecoder { public void decode() throws AndrolibException, IOException, DirectoryException { File outDir = getOutDir(); + AndrolibResources.sKeepBroken = mKeepBrokenResources; if (!mForceDelete && outDir.exists()) { throw new OutDirExistsException(); @@ -239,7 +240,6 @@ public class ApkDecoder { throw new AndrolibException( "Apk doesn't contain either AndroidManifest.xml file or resources.arsc file"); } - AndrolibResources.sKeepBroken = mKeepBrokenResources; mResTable = mAndrolib.getResTable(mApkFile, hasResources); } return mResTable; diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java index 497433f3..dea33ff4 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java @@ -249,8 +249,18 @@ public class ARSCDecoder { } ResResource res = new ResResource(mType, spec, value); - mType.addResource(res); - spec.addResource(res); + try { + mType.addResource(res); + spec.addResource(res); + } catch (AndrolibException ex) { + if (mKeepBroken) { + mType.addResource(res, true); + spec.addResource(res, true); + LOGGER.warning(String.format("Duplicate Resource Detected. Ignoring duplicate: %s", res.toString())); + } else { + throw ex; + } + } mPkg.addResource(res); }