Skip to content

Instantly share code, notes, and snippets.

@who
Created April 24, 2015 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save who/cdb37baffa7f64d27180 to your computer and use it in GitHub Desktop.
Save who/cdb37baffa7f64d27180 to your computer and use it in GitHub Desktop.
Counts methods in a jar. Useful for testing to see if a jar is going to contribute to the 65K method limit in Android
#!/bin/bash
if [ ! -e `which dx` ]
then
echo "Please make sure the dx executable (from android-sdk build-tools) is in your $PATH"
exit 1
fi
tmpFolder=$(mktemp -d /tmp/tmp.XXXXXXXX);
dx --dex --output=$tmpFolder/temp.dex $1 >> /dev/null 2>&1
cat $tmpFolder/temp.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
@who
Copy link
Author

who commented Apr 24, 2015

Usage:

To count methods in a single jar:

$ dexcount path/to_a_jar/myjar.jar

To count and total the methods in a directory of jars:

$ for jar in ./target/lib/*.jar; do dexcount $jar; done | paste -s -d+ | bc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment