Can i have the count of all methods used in a jar file . My APK uses certain external JARS and there are a number of classes around hundred to be precise.
I have use
For cases where you're already over the 64k method limit, an alternate approach would be to use the --multi-dex option to dx, and then use baksmali's "list methods" functionality on all of the dex files that dx generates. Next, you would combine these lists, sort the combined list and remove any duplicates. The number of methods you are left with will be the total method count.
dx --dex --multi-dex --output=out orig.jar
find out -name classes*.dex -exec baksmali list methods {} \; | sort | uniq | wc -l
This gradle plugin https://github.com/KeepSafe/dexcount-gradle-plugin will show you the total method count after assembling and also generates a report with the method count of each package. Which after being sorted looks like this:
30145 com
27704 org
20950 android
17140 org.spongycastle
16605 android.support
9760 com.google
8930 com.fasterxml.jackson
8930 com.fasterxml
8633 android.support.v4
7020 com.fasterxml.jackson.databind
6426 android.support.v7
5311 com.google.protobuf
4705 org.spongycastle.crypto
...
In combination with the gradle command
.\gradlew app:dependencies
which prints out the dependency tree you will get a good overview of which dependency needs how many methods.
(public|protected|private|static|\s) +[\w\<\>\[\]]+\s+(\w+) *\([^\)]*\) *(\{?|[^;])
Search in project using CTRL+SHIFT+F
. It helped me
Cyvis can read a .jar
or .class
file, and will show both total method counts plus cyclomatic complexity and instruction count for each method. The GUI is a bit ... portable ... but I've run it on Ubuntu and it says it works on Windows. Seems pretty good for a first-cut source of info on how likely a library is to give you trouble.
If you have the source code (or can download it), Sonar will do static analysis like this on it. You can also check a bunch of other complexity metrics which may be useful for what you're trying to do. (Might be nice to tell us what you're trying to do. ;) )
With the command line, after having unzipped the JAR, something like this should work :
for f in *.class; do javap -c $(basename -s .class $f) | grep invoke | sed 's/.*Method\(.*\)/\1/g'; done | wc -l