Search code examples
androiddexdex-limit

Showing dex method count by package


I'm working on android app that's running up against the dex method count limit. Is there a simple way to show the method count grouped by package? I can get the total method count, but my app has multiple components and I'm trying to figure out which component is the biggest contributor to this.


Solution

  • This will give you an idea of how much each package hierarchy contributes to the method count. The results include all classes in that directory/package and all subdirectories/packages.

    baksmali blah.apk -o out
    cd out
    find * -type d -print -exec sh -c "smali {} -o {}/classes.dex && sh -c \"dexdump -f {}/classes.dex | grep method_ids_size\"" \;
    

    This slightly modified version is similar, except that it is only for the classes in that particular directory/package, not including any subdirs/subpackages

    baksmali blah.apk -o out
    cd out
    find * -type d -print0 | xargs -0 -I{} sh -c "echo {} && find {} -maxdepth 1 -name \"*.smali\" -print0 | xargs -r -0 smali -o {}/classes.dex"
    find -name "*.dex" -print -exec sh -c "dexdump -f {} | grep method_ids_size" \;