5

Whilst eclipse tells me about unreferenced variables, classes and imports, it doesn't tell me if there are values in the resource files that are not used.

Being able to remove everything that is not used would be very useful from a translation point of view.

Is there a tool out there that can do this?

Chris Simpson
  • 7,821
  • 10
  • 48
  • 68

3 Answers3

3

Option 1:

NOTE: Does not work for resources referenced directly in xml and ids loaded through reflection.

Considering that generated ids of all resources are located inside your R.java file this should be possible using the Eclipse Core Tools.

The menu option looks like this: Find Unreferenced Members

Option 2:

Android Unused Resources is a Java application that will scan your project for unused resources. Unused resources needlessly take up space, increase the build time, and clutter the IDE's autocomplete list.

http://code.google.com/p/android-unused-resources/

mibollma
  • 14,959
  • 6
  • 52
  • 69
0

Android Lint is your friend. Inside the ant project, just type

ant lint

It will give a UnusedResource warning in such cases.

Community
  • 1
  • 1
serv-inc
  • 35,772
  • 9
  • 166
  • 188
0

The simplest (and slowest) way that I can think of is to delete them, one by one, and let eclipse rebuild your project. If it produces an error, then you know it was used, otherwise, you're ok without it.

Travis
  • 3,737
  • 1
  • 24
  • 24
  • I thought about this but it takes roughly 20 seconds to build my project (on a good day) meaning it would take several hours to complete this. Also, if there is only a reference in a layout file, do you still get a compile error? – Chris Simpson Aug 16 '11 at 17:19
  • I think you do. Another approach would depend on the tools you have installed (to a lesser degree, the os you're running on). It would be possible to write a bash script that employed the use of find and grep to determine if the string was used anywhere in a .java or .xml file, then you could know that the string's name wasn't referenced anywhere, and perform the above suggested work on a smaller subset of the data rather than everything. It's just a thought – Travis Aug 16 '11 at 19:23