diff --git a/CHANGES b/CHANGES index 3b5eb9da..b43b1bd9 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,7 @@ v2.0.0 (TBA) -Fixed (issue #510) - Any error output is sent stderr instead of stdout -Fixed (issue #426) - Filename too long (JesusFreke) -Fixed (issue #524) - INSTALL_FAILED_DEXOPT fix (JesusFreke) +-Fixed (issue #473) - multiple package frameworks are treated correctly. -Added output to list Apktool version to help debugging. -Updated known bytes for configurations to 38 (from addition of layout direction) -Fixed NPE when handling odex apks even with --no-src specified. (Thanks Rodrigo Chiossi) 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 ef617540..1805de4d 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 @@ -425,13 +425,35 @@ public class ARSCDecoder { } public ResPackage getOnePackage() throws AndrolibException { - if (mPackages.length != 1) { - throw new AndrolibException( - "Arsc file contains zero or multiple packages"); + if (mPackages.length <= 0) { + throw new AndrolibException( + "Arsc file contains zero packages"); + } else if (mPackages.length != 1) { + int id = findPackageWithMostResSpecs(); + LOGGER.warning("Arsc file contains multiple packages. Using package " + mPackages[id].getName() + " as default."); + return mPackages[id]; } return mPackages[0]; } + public int findPackageWithMostResSpecs() { + int count = -1; + int id = 0; + + // set starting point to package id 0. + count = mPackages[0].getResSpecCount(); + + // loop through packages looking for largest + for (int i = 0; i < mPackages.length; i++) { + if (mPackages[i].getResSpecCount() >= count) { + count = mPackages[i].getResSpecCount(); + id = i; + } + } + + return id; + } + public ResTable getResTable() { return mResTable; }