Darren
Darren

Reputation: 165

Incorrect Android Lint warning on Unused Resources

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.

Upvotes: 6

Views: 3343

Answers (1)

Phant&#244;maxx
Phant&#244;maxx

Reputation: 38098

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).

enter image description here

Upvotes: 5

Related Questions