In Android Studio there is a shortcut available. 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.
Normally you can find string. xml in res->values folder path.
A single string that can be referenced from the application or from other resource files (such as an XML layout). Note: A string is a simple resource that is referenced using the value provided in the name attribute (not the name of the XML file).
On Android Studio:
Menu -> Analyze -> Run Inspection by Name -> Unused resources
Check File mask(s) checkbox and put strings.xml
in the text field.
Here is another solution that is fairly easy. In the Android Studio menu go to
Refactor > Remove Unused Resources....
Click Preview to see what the unused resources are and selectively remove them.
In my case "Run Inspection by Name" didnt work, despite the fact I was using "Remove unused resources".
Solution:
I have no clue why "Remove Unused Resources" works one way but not the other.
With ADT 16 you can do it as simple as possible. Update to ADT 16 and use Android Lint. It is really amazing tool. It can find all unused resources (not only strings) and many more. From its official site:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With