Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find all unused methods of my project in the Android Studio IDE?

How can I find all unused methods and variables of my project in the Android Studio IDE?

like image 800
Hamed Ghadirian Avatar asked Nov 12 '15 15:11

Hamed Ghadirian


People also ask

How to find unused classes in Android Studio?

To run it on whole project go to Analyze -> Run inspection by name... , type Unused declaration and select desired scope. Then carefully check output and mark some classes as entry points if needed. Now you can select Unused declaration node in list and perform Safe delete action on all unused declarations at once.


Video Answer


2 Answers

In the android studio(or more generally in the Intellij IDEA) you can specify inspection code that you want to analyze from Analyze->Inspect Code... and then define the scope of your code. You can see the result for my code in the below picture:

enter image description here

In Declaration redundancy you can see that "someMethod" is declared unused. Also, in Probable bugs you can find variable i is never used.

like image 112
Hamed Ghadirian Avatar answered Sep 21 '22 16:09

Hamed Ghadirian


You can also install the QAPlug via File -> Settings -> Plugins -> Browse Repositories -> QAPlug.

For Mac:

Android Studio -> Preferences... -> Plugins -> Browse Repositories -> QAPlug. 

In QAPlug is PMD, FindBugs, Checkstyle and Hammurapi integrated. These tools are very nice to find dead code, bugs, increase performance and make the code more readable. I highly recommend those tools if you work for a bigger project.

like image 29
Erythrozyt Avatar answered Sep 23 '22 16:09

Erythrozyt