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

- 3,129
- 2
- 33
- 80

- 6,159
- 7
- 48
- 67
-
9Mr. DownVoter, may I ask you why you down vote this question? – Hamed Ghadirian Nov 12 '15 at 15:14
-
5Not my downvote, but maybe it was someone who read the first words of the title and thought your question falls in an off-topic category: "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." I don't think your question is off-topic, but you might want to change the title to "How can I find..." as you wrote in the question body, to prevent misunderstandings. – Fabio says Reinstate Monica Nov 12 '15 at 16:03
3 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:
In Declaration redundancy
you can see that "someMethod" is declared unused. Also, in Probable bugs
you can find variable i
is never used.

- 5,544
- 7
- 36
- 51

- 6,159
- 7
- 48
- 67
-
2And an easy way to get the job done. Thanks to both of you guys. – Sakhawat Hossain Jan 26 '20 at 15:30
-
1Why is this setting not sticky? Every time I open Android Studio I have to recheck this setting. And I always explicitly Apply and press Ok. – doctorram May 29 '22 at 06:43
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.

- 3,129
- 2
- 33
- 80

- 802
- 6
- 21
-
-
-
Android 3.0, installed pluging, keeps crashing on AS restart or if I try to use it... Anyone got it working with AS 3.0? – 3c71 Nov 04 '17 at 13:52
Nowadays its in Analyze->Inspect Code... and then you need to go to Kotlin | Redundant contructs | Unused symbol

- 3,533
- 1
- 21
- 21