Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove all unused classes,methods from Android Studio project

I have used the lint(Analyze->Inspect Code...) and find out unused methods and resources. All the unused resources removed by Refractor->Remove unused Resources but not found any option like this to remove java classes and methods. Is there any feature in the android studio or any Plugin which can remove all the java classes, the methods which are not used in code to save manual refracting?

like image 350
bilal Avatar asked May 06 '16 07:05

bilal


People also ask

How do I delete unused resources in Android?

In Android Studio Menu > Refactor > Remove Unused Resources... Select the resources you want to remove. You can exclude resources you want to keep by right-clicking on the resource item. Use Do Refactor to remove all Resources at once.

How to remove unused variables in Android Studio?

“remove unused resources android studio” Code Answer Just press Ctrl Alt Shift i and type "unused resources" (without quotes). That will execute lint.

Where is unused method in Android Studio?

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


1 Answers

This can be achieved by using the built-in inspection Java | Declaration redundancy | Unused declaration.

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.

Inspection result

For Kotlin there is similar inspection Kotlin | Redundant constructs | Unused symbol.

like image 137
KursoR Avatar answered Sep 20 '22 11:09

KursoR