Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unused String and Image Resources in Android

Tags:

android

My project has a large number of String and ImageResources, many of which i feel are unused. Is there any way i can find out which of these resources are currently not been referenced from my code?

like image 709
user1730789 Avatar asked Apr 25 '13 09:04

user1730789


4 Answers

In Android Studio (tried up to Version 2.1.3), you can simply go to Main Menu -> Analyze -> Run Inspection by Name..., and select Unused resources

enter image description here

(It runs Android Lint for you.)

like image 145
Alex Vang Avatar answered Nov 12 '22 12:11

Alex Vang


In Android Studio there is a shortcut available.

Press Ctlr + Alt + Shift + i (or Cmd + Option + Shift + i on Mac)

This will open a dialog in which you can type "Unused" to see a number of options.

I generally type "unused resources" and get a list including layouts, strings, drawables, etc.

like image 24
Shrini Jaiswal Avatar answered Nov 12 '22 12:11

Shrini Jaiswal


In Android Studio 2.0 and above

in menu select Refactor-->click on Remove Unused Resources...

like image 9
Ramesh R Avatar answered Nov 12 '22 11:11

Ramesh R


Improving @Ramesh R answer, the best way is Right click on your res folder, Select Refactor and Remove Unused Resources.

This tool is fantastic, my applauses to his developer xD;

like image 6
Ernesto Vega Avatar answered Nov 12 '22 11:11

Ernesto Vega