How to find unused resources in your Android project

UPDATE:

This was written prior to the release of Android Lint, so it’s no longer really necessary. Running lint will do the same thing.

Design changes!
They happen all the time. At least they do on our project, and let’s face it, designers don’t always stick to naming conventions meant to prevent asset duplication.
In any case, i’m not casting blame. Orphaned resources happen pretty easily. Luckily there’s a great tool to help you keep track of the stuff in your project that’s not being used.
With it you can find unused strings in your android project.
Find unused raw assets in your android project.
Find unused drawables in your android project.
Find unused layouts in your android project.

Check it out!
android-unused-resources – Android Unused Resource Detector – Google Project Hosting

android-unused-resources – Android Unused Resource Detector – Google Project Hosting.

It does have some imperfections. You’ll sometimes get false positives. For example:
If you’re getting a dynamic reference to a resource, this tool won’t catch that (not that I would expect it to). But that’s just a minor thing.
Anyway thanks @google!

Leave a Reply

Your email address will not be published. Required fields are marked *