Is there a tool for finding unused resources in an Android project?

I would like to find unused resources in my Android project - this includes strings, identifiers, drawings, integers, etc.

Is there a tool for this currently (preferably for Eclipse)?

+43
android find resources
Apr 28 '11 at 20:09
source share
5 answers

If you use IntelliJ, which has Android support in the free version of the community, you can do this by opening the generated R.java file (gen / R.java). Unused resources will be marked with a warning that you are not referencing anywhere in your project.

I would be surprised if Eclipse does not do the same.

+18
Apr 28 2018-11-21T00:
source share
— -

Friendly note. The IntelliJ idea ONLY works for resources that are not referenced by JAVA code. So, if you have 1,500 resources and only 20 links are directly from your java code, you will get 1,480 unused warnings in this file.

I see things marked as unused, which I can clearly see, are used in different layouts. So keep that in mind ... don't go on a trifle.

+34
Jul 11 '11 at 18:34
source share

Update ADT 16 and use Android Lint . This is a really awesome tool.

Android Lint is a new tool for ADT 16 (and 16 tools) that scans the sources of an Android project for possible errors.

Here are some examples of the types of errors that it looks for: - Missing translations (and unused translations) - Layout performance problems (all the issues the old layoutopt tool used to find, and more) - Unused resources - Inconsistent array sizes (when arrays are defined in multiple configurations) - Accessibility and internationalization problems (hardcoded strings, missing contentDescription, etc) - Icon problems (like missing densities, duplicate icons, wrong sizes, etc) - Usability problems (like not specifying an input type on a text field) - Manifest errors and many more. 
+34
Dec 14 '11 at 16:55
source share

Andrey Bunoe rights to Android Lint - this is the way. To specifically answer a question for any other user, the command:

lint --check UnusedResources <path to project>

There are many more options in lint that you can see with lint --list .

+19
May 2, '13 at 23:45
source share

android-unused-resources is a Java tool that will detect unused resources and tell you where they are. It processes Java and XML files, so it avoids the problem in the accepted answer.

This is not ideal, but as long as you do not dynamically load resources ( getIdentifier ( java.lang.String, java.lang.String, java.lang.String )), It shouldn’t tell you to delete everything that is actually actually used (although you get a compiler error, even if that happens).

+5
Aug 05 '11 at 5:11
source share



All Articles