Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange Lint Warning - Unexpected text found in layout file: ""

I've got the following selector defined in button_selector.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
       <item android:state_pressed="true" 
           android:state_enabled="true"
           android:drawable="@drawable/button_settlement_background_pressed" />
       <item android:state_enabled="true"
           android:drawable="@drawable/button_settlement_background_normal" />
       <item android:state_enabled="false"
           android:drawable="@drawable/button_settlement_background_disabled" />
       </selector>

When I run lint I get the following warning: Unexpected text found in layout file: "". It says it's happening at line 4 in "drawable". All of the referenced drawables exist in /res/drawable.

Does anyone know what could be causing this? I can ignore the warning but I'd rather fix it if possible.

Also, I get warnings for unused strings and icons when they're only referenced in AndroidManifest.xml. Is there a way to fix those instead of ignoring them?

like image 449
Ginger McMurray Avatar asked Jun 13 '12 15:06

Ginger McMurray


2 Answers

Using Project>Clean.

Fixed that problem in my case.

like image 149
vezucci Avatar answered Sep 28 '22 09:09

vezucci


Perhaps there's an invisible character somewhere in the white space. I'd try recreating the xml from scratch (not using copy-and-paste, which would just copy the problem, if that's what's happening). I'd also clean and rebuild the project.

As far as the unused resource warnings, I don't think there's a way to control this. The problem of false positives is hugely worse for library projects. Android lint is a fairly new tool and (in my opinion) still has a lot of rough edges.

like image 38
Ted Hopp Avatar answered Sep 28 '22 09:09

Ted Hopp