Reputation: 20100
I'm encountering issues with my application having too many methods.
In the last post in the below link, a poster posts the method count for his application (broken down by package). I unable to find how I can get this information for my application, any suggestions?
https://code.google.com/p/android/issues/detail?id=20814
Upvotes: 19
Views: 11184
Reputation: 452
If you have already built application, then you can use dexdump (AOSP tool) for this:
# Get the number of classes.
dexdump -h ApkName.apk | grep "^class_idx" | wc -l
# Get the number of methods.
dexdump -h ApkName.apk | grep "method_idx" | wc -l
Upvotes: 0
Reputation: 12308
To get a method-count report on every build, do this:
in app/build.gradle
:
buildscript {
repositories {
mavenCentral() // or jcenter()
}
dependencies {
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.3'
}
}
// make sure this line comes *after* you apply the Android plugin
apply plugin: 'com.getkeepsafe.dexcount'
It will show the number of methods per package, for your own project and the libraries you use.
From: https://github.com/KeepSafe/dexcount-gradle-plugin
Upvotes: 13
Reputation: 2391
To find and Android app method count with or without multidex support use:
find | grep classes.dex | xargs -I {} hexdump -e '"%d {}\n"' -s 0x58 -n 4 {}
Upvotes: 0
Reputation: 6205
Have you tried https://github.com/KeepSafe/dexcount-gradle-plugin? Shows you the number of methods per package graphically and/or text.
Upvotes: 0
Reputation: 4837
You can use APK Analyzer in the Android studio
https://developer.android.com/studio/build/apk-analyzer.html
Upvotes: 6
Reputation: 5087
There is a tool APK method count which counts the number of methods in your apk.
There is also a service methodscount.com to check method count of libraries. This service also has Android Studio/IntelliJ plugin that parses your Android library dependencies and shows the methods count as an handy hint.
Upvotes: 5
Reputation: 3844
I use
cat build/dex/debug/classes.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
I get 55176
. 64k limit is coming :D
Upvotes: 31
Reputation: 1246
You could use JavaNCSS to get such statistics. It is available here: http://www.kclee.de/clemens/java/javancss/
Upvotes: 1
Reputation: 82563
Try to use a static code analyzer; Source Monitor, for example, is free SW and has the count you're searching for.
Or if you prefer to do it without additional plugins, try doing this (Eclipse only):
After the search is complete you should see a "XXXX declarations in..." message in the search view and that will be your result.
Hope it helps!
Upvotes: 4