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

JavaAndroidAndroid StudioIntellij Idea

Java Problem Overview


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

Java Solutions


Solution 1 - Java

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.

Solution 2 - Java

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.

Solution 3 - Java

Nowadays its in Analyze->Inspect Code... and then you need to go to Kotlin | Redundant contructs | Unused symbol

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHamed GhadirianView Question on Stackoverflow
Solution 1 - JavaHamed GhadirianView Answer on Stackoverflow
Solution 2 - JavaErythrozytView Answer on Stackoverflow
Solution 3 - JavaJacob NordfalkView Answer on Stackoverflow