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.
In Android Studio Menu > Refactor > Remove Unused Resources... Select the resources you want to remove. You can exclude resources you want to keep by right-clicking on the resource item. Use Do Refactor to remove all Resources at once.
To suppress a lint warning with a comment, add a //noinspection id comment on the line before the statement with the error. Here we specify a comma separated list of issue id's after the disable command. You can also use warning or error instead of disable to change the severity of issues.
The lint tool checks for structural code problems that could affect the quality and performance of your Android application. It is strongly recommended that you correct any errors that lint detects before publishing your application.
Module and file-specific preferences Run the lint tool on your module by right-clicking on your module folder or file in the Project View and selecting Analyze > Inspect Code. This displays the lint inspection results with a list of issues that lint detected in your module.
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).
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