Incorrect Android Lint warning on Unused Resources

android, eclipse, java, lint

Solution

Lint often produces false positives on unused resources.

You can set them to `Information` or `Ignore` instead of `Warning` (Window/Preferences/Android/Lint Error Checking/Performance/UnusedResources).

Problem

After I run Lint in Eclipse, it shows a list of unused resources, mainly drawable. Some of them are incorrect. It is saying that some of the resource are unused, but in fact, it is actually being used in array.xml. E.g. The resource R.drawable.test appears to be unused In array.xml, ``` <string-array name="icon"> <item>test</item> </string-array> ``` Then in my activity, I use following code to retrieve the resource ``` String[] icon = getResources().getStringArray(icon); iconRes = getResources().getIdentifier(icon[itemPos], "drawable", this.getPackageName()); ``` I tried to run lint in terminal and it's giving the same result.

Original source