Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine application's method count?

Tags:

java

android

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

like image 233
ab11 Avatar asked Mar 19 '13 20:03

ab11


People also ask

How do I count the number of methods in a Java class in Eclipse?

Please press CTRL+O in your respective Java Class in the Eclipse IDE - You will get the number of methods in the respective Java class.

How many methods are there in Java?

There are two types of methods in Java: Predefined Method. User-defined Method.

How can I see all methods in Android Studio?

Open your file in editor and click on structure tab, it will show all the methods in the class selected. Click on any method and you will be redirected to that method. Show activity on this post. You can use CTRL + F12 shortcut in windows for that purpose.


2 Answers

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

like image 112
Ivan Morgillo Avatar answered Oct 05 '22 05:10

Ivan Morgillo


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

like image 21
Frank Avatar answered Oct 05 '22 06:10

Frank