I'd like to find any unused resources in my Android project - this includes strings, ids, drawables, integers etc.
Does a tool to do this currently exist (preferably for Eclipse)?
I'd like to find any unused resources in my Android project - this includes strings, ids, drawables, integers etc.
Does a tool to do this currently exist (preferably for Eclipse)?
If you use IntelliJ, which has Android support in the free community edition, you can do this by opening the generated R.java file (gen/R.java). The unused resources will be marked with a warning for not being referenced anywhere in your project.
I'd be surprised if Eclipse doesn't do the same thing.
android-unused-resources is a Java tool that will detect unused resources, and tell you where they are located. It processes Java and XML files, so it avoids the problem in the accepted answer.
It's not perfect, but as long as you don't dynamically load resources (getIdentifier(
java.lang.String, java.lang.String, java.lang.String
)), It shouldn't tell you to delete any that are actually being used (although you'll get a compiler error even if that happens).A friendly note: The IntelliJ idea ONLY works for resources that are not referenced in JAVA code. So if you have 1500 resources and only 20 are referenced directly from your java code, you end up with 1480 unused warnings in that file.
I'm seeing things marked as unused that I can clearly see are in use in various layouts. So keep that in mind ... don't go on a deleting spree.
Andrei Buneyeu is right to Android Lint is the way to go. To specifically answer the question for anyone else looking, the command is:
lint --check UnusedResources <path to project>
There are a lot more options in lint that you can see with
lint --list
.Update to ADT 16 and use Android Lint. It is really amazing tool.