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 16a3395145..38c20897d4 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 @@ -270,7 +270,9 @@ private ResType readTableType() throws IOException, AndrolibException { mHeader.checkForUnreadHeader(mIn); - if ((typeFlags & 0x01) != 0) { + // Be sure we don't poison mResTable by marking the application as sparse + // Only flag the ResTable as sparse if the main package is not loaded. + if ((typeFlags & 0x01) != 0 && !mResTable.isMainPkgLoaded()) { mResTable.setSparseResources(true); } diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/SparseFlagTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/SparseFlagTest.java index 276fbf63ed..c3959250f4 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/SparseFlagTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/SparseFlagTest.java @@ -54,6 +54,7 @@ public void decodeWithExpectationOfSparseResources() throws BrutException, IOExc LOGGER.info("Decoding sparse.apk..."); Config config = Config.getDefaultConfig(); + config.frameworkTag = "issue-3298"; ApkDecoder apkDecoder = new ApkDecoder(config, testApk); ApkInfo apkInfo = apkDecoder.decode(sTestNewDir); @@ -70,6 +71,7 @@ public void decodeWithExpectationOfNoSparseResources() throws BrutException, IOE LOGGER.info("Decoding not-sparse.apk..."); Config config = Config.getDefaultConfig(); + config.frameworkTag = "issue-3298"; ApkDecoder apkDecoder = new ApkDecoder(config, testApk); ApkInfo apkInfo = apkDecoder.decode(sTestNewDir);