Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove all unused resources from an android project

I want to remove all unused layouts, strings, drawables, colors, etc from my Android res directory. Are there any tools that will give me a list of files and I can remove from my repository and elements within specifics files (e.g. unused string entries) that are no longer used?

like image 749
Steve Prentice Avatar asked Jun 16 '11 14:06

Steve Prentice


People also ask

How to remove unused code in android?

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.

Should I delete unused Android Studio directories?

TL;DR: No. It will not cause any problems. Hidden folders in your home directory should contain only application settings.


1 Answers

You can easily search for unused resources from Android Studio. Just press CtrlAltShifti and type "unused resources" (without quotes). That will execute lint. Super easy way to run lint commands (and other stuff from IDE).

OR

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.

Update: use OptionShifti for mac

like image 102
bakua Avatar answered Sep 24 '22 19:09

bakua