Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Lint - How to hide a warning 'The resource Xxx appears to be unused'

Tags:

I'd like to disable the (new) Android Lint warning 'The resource Xxx appears to be unused' for some specific resources.

For other Lint warning I was ableto take advantage of Quick Assist, which showed 3 choices to disable the warning, one of those was for that particular file.

But this warning does not show any Quick Assist, it appears in Eclipse with the generic yellow warning color on top of a file (the one defining the resource).

I tried also manually editing the lint.xml file like in the following:

<lint>   <issue id="UnusedResources">     <ignore path="res\layout\my_layout.xml" />   </issue> <lint> 

but with no luck (I picked up the id from an Android Lint reference here).

like image 314
superjos Avatar asked Dec 21 '11 09:12

superjos


1 Answers

I had this problem today and found the Improving Your Code with lint page to be very helpful. In the "Configuring lint checking in XML" section, it describes how to ignore specific resources:

You can use the tools:ignore attribute to disable lint checking for specific sections of your XML files. In order for this attribute to be recognized by the lint tool, the following namespace value must be included in your XML file:

namespace xmlns:tools="http://schemas.android.com/tools"

Then you are able to add tools:ignore="UnusedResources" to the resources to ignore.

like image 117
meisteg Avatar answered Sep 21 '22 17:09

meisteg